Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fix: web packaging, cleaning old config files

Ilian Sapundshievcddf30623bf3
diff --git a/configs/webpack.config.base.js b/configs/webpack.config.base.js
deleted file mode 100644
index 970157813..000000000
--- a/configs/webpack.config.base.js
+++ /dev/null
@@ -1,82 +0,0 @@
-/**
- * Base webpack config used across other specific configs
- */
-
-import path from 'path';
-import webpack from 'webpack';
-const Dotenv = require('dotenv-webpack');
-// import { dependencies } from '../package.json';
-
-export default {
- // externals: [...Object.keys(dependencies || {})],
- externals: [
- {
- fsevents: "require('fsevents')",
- },
- {
- fswin: "require('fswin')",
- },
- ],
-
- module: {
- rules: [
- {
- test: /\.[jt]sx?$/,
- exclude: /node_modules/,
- // include: [/app/],
- use: [
- {
- loader: 'babel-loader',
- options: {
- cacheDirectory: true,
- },
- },
- {
- loader: 'ts-loader',
- options: {
- transpileOnly: true,
- experimentalWatchApi: true,
- },
- },
- ],
- },
- ],
- },
-
- output: {
- path: path.join(__dirname, '..', 'app'),
- // https://github.com/webpack/webpack/issues/1114
- libraryTarget: 'commonjs2',
- pathinfo: false,
- },
-
- /**
- * Determine the array of extensions that should be used to resolve modules.
- */
- resolve: {
- extensions: ['.mjs', '.js', '.ts', '.tsx', '.json'],
- modules: [path.join(__dirname, '..', 'app'), 'node_modules'],
- },
-
- cache: {
- type: 'filesystem',
- buildDependencies: {
- config: [__filename],
- },
- },
-
- plugins: [
- new webpack.EnvironmentPlugin({
- NODE_ENV: 'production',
- }),
- new Dotenv({
- path: path.join(
- __dirname,
- '..',
- 'node_modules',
- '@tagspaces/tagspaces-common/default.env',
- ),
- }),
- // new webpack.NamedModulesPlugin()
- ],
-};
diff --git a/configs/webpack.config.eslint.js b/configs/webpack.config.eslint.js
deleted file mode 100644
index bd000487d..000000000
--- a/configs/webpack.config.eslint.js
+++ /dev/null
@@ -1,4 +0,0 @@
-/* eslint import/no-unresolved: off, import/no-self-import: off */
-require('@babel/register');
-
-module.exports = require('./webpack.config.renderer.dev.babel').default;
diff --git a/configs/webpack.config.main.prod.babel.js b/configs/webpack.config.main.prod.babel.js
deleted file mode 100644
index 9dde7393d..000000000
--- a/configs/webpack.config.main.prod.babel.js
+++ /dev/null
@@ -1,96 +0,0 @@
-/**
- * Webpack config for production electron main process
- */
-
-import path from 'path';
-import webpack from 'webpack';
-import merge from 'webpack-merge';
-import TerserPlugin from 'terser-webpack-plugin';
-import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
-import baseConfig from './webpack.config.base';
-// import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
-
-// CheckNodeEnv('production');
-
-const targetPlatform = 'electron-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
-
-export default merge(baseConfig, {
- devtool: 'source-map',
-
- mode: 'production',
-
- target: 'electron-main',
-
- entry: './app/main.dev',
-
- output: {
- path: path.join(__dirname, '..'),
- filename: './app/main.prod.js',
- },
-
- optimization: {
- minimizer: process.env.E2E_BUILD
- ? []
- : [
- new TerserPlugin({
- parallel: true,
- // sourceMap: true,
- // cache: true
- }),
- '...', // '...' can be used in optimization.minimizer to access the defaults.
- ],
- },
-
- plugins: [
- new BundleAnalyzerPlugin({
- analyzerMode:
- process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled',
- openAnalyzer: process.env.OPEN_ANALYZER === 'true',
- }),
-
- /* new webpack.NormalModuleReplacementPlugin(
- /(.*)_PLATFORMIO_(\.*)/,
- resource => {
- resource.request = resource.request.replace(
- /_PLATFORMIO_/,
- `${targetPlatform}`
- );
- }
- ), */
-
- /* new webpack.NormalModuleReplacementPlugin(
- /(.*)_PDFDISTLIB_(\.*)/,
- resource => {
- resource.request = resource.request.replace(
- /_PDFDISTLIB_/,
- `pdfjs-dist/webpack`
- );
- }
- ), */
-
- /**
- * Create global constants which can be configured at compile time.
- *
- * Useful for allowing different behaviour between development builds and
- * release builds
- *
- * NODE_ENV should be production so that modules do not perform certain
- * development checks
- */
- new webpack.EnvironmentPlugin({
- NODE_ENV: 'production',
- DEBUG_PROD: false,
- START_MINIMIZED: false,
- }),
- ],
-
- /**
- * Disables webpack processing of __dirname and __filename.
- * If you run the bundle in node.js it falls back to these values of node.js.
- * https://github.com/webpack/webpack/issues/2010
- */
- node: {
- __dirname: false,
- __filename: false,
- },
-});
diff --git a/configs/webpack.config.renderer.dev.babel.js b/configs/webpack.config.renderer.dev.babel.js
deleted file mode 100644
index 24ac7e913..000000000
--- a/configs/webpack.config.renderer.dev.babel.js
+++ /dev/null
@@ -1,342 +0,0 @@
-/* eslint global-require: off, import/no-dynamic-require: off */
-
-/**
- * Build config for development electron renderer process that uses
- * Hot-Module-Replacement
- *
- * https://webpack.js.org/concepts/hot-module-replacement/
- */
-
-import path from 'path';
-import fs from 'fs';
-import webpack from 'webpack';
-import chalk from 'chalk';
-import merge from 'webpack-merge';
-import { spawn, execSync } from 'child_process';
-import baseConfig from './webpack.config.base';
-// import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
-
-// CheckNodeEnv('development');
-
-const targetPlatform = 'electron-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
-
-const port = process.env.PORT || 1212;
-const publicPath = `http://localhost:${port}/dist`;
-const dll = path.join(__dirname, '..', 'dll');
-const manifest = path.resolve(dll, 'renderer.json');
-const requiredByDLLConfig = module.parent.filename.includes(
- 'webpack.config.renderer.dev.dll',
-);
-
-/**
- * Warn if the DLL is not built
- */
-if (!requiredByDLLConfig && !(fs.existsSync(dll) && fs.existsSync(manifest))) {
- console.log(
- chalk.black.bgYellow.bold(
- 'The DLL files are missing. Sit back while we build them for you with "yarn build-dll"',
- ),
- );
- execSync('npm run build-dll');
-}
-
-export default merge(baseConfig, {
- cache: false,
- devtool: 'eval-source-map', // inline-source-map
-
- mode: 'development',
-
- target: 'electron-renderer',
-
- entry: [
- // 'react-hot-loader/patch',
- `webpack-dev-server/client?http://localhost:${port}/`,
- 'webpack/hot/only-dev-server',
- require.resolve('../app/index.tsx'),
- ],
-
- output: {
- publicPath: `http://localhost:${port}/dist/`,
- filename: 'renderer.dev.js',
- },
-
- module: {
- rules: [
- {
- test: /\.global\.css$/,
- use: [
- {
- loader: 'style-loader',
- },
- {
- loader: 'css-loader',
- options: {
- sourceMap: true,
- },
- },
- ],
- },
- {
- test: /^((?!\.global).)*\.css$/,
- use: [
- {
- loader: 'style-loader',
- },
- {
- loader: 'css-loader',
- options: {
- modules: {
- localIdentName: '[name]__[local]__[hash:base64:5]',
- },
- sourceMap: true,
- importLoaders: 1,
- },
- },
- ],
- },
- // SASS support - compile all .global.scss files and pipe it to style.css
- {
- test: /\.global\.(scss|sass)$/,
- use: [
- {
- loader: 'style-loader',
- },
- {
- loader: 'css-loader',
- options: {
- sourceMap: true,
- },
- },
- {
- loader: 'sass-loader',
- },
- ],
- },
- // SASS support - compile all other .scss files and pipe it to style.css
- {
- test: /^((?!\.global).)*\.(scss|sass)$/,
- use: [
- {
- loader: 'style-loader',
- },
- {
- loader: 'css-loader',
- options: {
- modules: {
- localIdentName: '[name]__[local]__[hash:base64:5]',
- },
- sourceMap: true,
- importLoaders: 1,
- },
- },
- {
- loader: 'sass-loader',
- },
- ],
- },
- {
- test: /\.(woff|woff2|eot|ttf|otf)$/i,
- type: 'asset/resource',
- generator: {
- filename: 'fonts/[hash][ext][query]',
- },
- },
- /*{
- test: /\.(eot|woff|ttf|svg|woff2)$/,
- use: [
- {
- loader: 'file-loader',
- options: {
- name: "[path][name].[ext]"
- }
- }
- ]
- },*/
- // WOFF Font
- /* {
- test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
- use: {
- loader: 'url-loader',
- options: {
- limit: 10000,
- mimetype: 'application/font-woff'
- }
- },
- // type: 'javascript/auto'
- },
- // WOFF2 Font
- {
- test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
- use: {
- loader: 'url-loader',
- options: {
- limit: 10000,
- mimetype: 'application/font-woff'
- }
- },
- // type: 'javascript/auto'
- }, */
- // TTF Font
- /* {
- test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
- use: {
- loader: 'url-loader',
- options: {
- limit: 10000,
- mimetype: 'application/octet-stream'
- }
- },
- type: 'javascript/auto'
- },
- // EOT Font
- {
- test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
- use: 'file-loader',
- type: 'javascript/auto'
- }, */
- // SVG Font
- {
- test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
- use: {
- loader: 'url-loader',
- options: {
- limit: 10000,
- mimetype: 'image/svg+xml',
- },
- },
- type: 'javascript/auto',
- },
- // Text files
- {
- test: /\.(txt)$/,
- use: 'raw-loader',
- type: 'javascript/auto',
- },
- // Common Image Formats
- {
- test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/,
- type: 'asset/resource',
- },
- ],
- },
-
- plugins: [
- requiredByDLLConfig
- ? null
- : new webpack.DllReferencePlugin({
- context: path.join(__dirname, '..', 'dll'),
- manifest: require(manifest),
- sourceType: 'var',
- }),
-
- new webpack.HotModuleReplacementPlugin({
- multiStep: true,
- }),
-
- /* new webpack.NormalModuleReplacementPlugin(
- /(.*)_PLATFORMIO_(\.*)/,
- resource => {
- resource.request = resource.request.replace(
- /_PLATFORMIO_/,
- `${targetPlatform}`
- );
- }
- ), */
-
- /* new webpack.NormalModuleReplacementPlugin(
- /(.*)_PDFDISTLIB_(\.*)/,
- resource => {
- resource.request = resource.request.replace(
- /_PDFDISTLIB_/,
- `pdfjs-dist/webpack`
- );
- }
- ), */
-
- new webpack.NoEmitOnErrorsPlugin(),
-
- /**
- * Create global constants which can be configured at compile time.
- *
- * Useful for allowing different behaviour between development builds and
- * release builds
- *
- * NODE_ENV should be production so that modules do not perform certain
- * development checks
- *
- * By default, use 'development' as NODE_ENV. This can be overriden with
- * 'staging', for example, by changing the ENV variables in the npm scripts
- */
- new webpack.EnvironmentPlugin({
- NODE_ENV: 'development',
- }),
-
- new webpack.LoaderOptionsPlugin({
- debug: true,
- }),
- ],
-
- node: {
- __dirname: false,
- __filename: false,
- },
-
- devServer: {
- port,
- compress: true,
- client: {
- overlay: {
- warnings: false,
- errors: false,
- },
- },
- // noInfo: true,
- devMiddleware: {
- // index: true,
- stats: 'errors-only',
- // mimeTypes: { "text/html": ["phtml"] },
- // publicPath: "/publicPathForDevServe",
- // serverSideRender: true,
- // writeToDisk: true,
- },
- // inline: true,
- // lazy: false,
- hot: true,
- headers: { 'Access-Control-Allow-Origin': '*' },
- static: {
- directory: path.join(__dirname, 'dist'),
- staticOptions: {},
- // Don't be confused with `devMiddleware.publicPath`, it is `publicPath` for static directory
- // Can be:
- // publicPath: ['/static-public-path-one/', '/static-public-path-two/'],
- publicPath,
- // Can be:
- // serveIndex: {} (options for the `serveIndex` option you can find https://github.com/expressjs/serve-index)
- // serveIndex: true,
- // Can be:
- // watch: {} (options for the `watch` option you can find https://github.com/paulmillr/chokidar)
- watch: {
- aggregateTimeout: 300,
- ignored: /node_modules/,
- poll: 100,
- },
- },
- historyApiFallback: {
- verbose: true,
- disableDotRule: false,
- },
- setupMiddlewares(middlewares, devServer) {
- if (process.env.START_HOT) {
- console.log('Starting Main Process...');
- spawn('npm', ['run', 'start-main-dev'], {
- shell: true,
- env: process.env,
- stdio: 'inherit',
- })
- .on('close', (code) => process.exit(code))
- .on('error', (spawnError) => console.error(spawnError));
- }
- return middlewares;
- },
- },
-});
diff --git a/configs/webpack.config.renderer.dev.dll.babel.js b/configs/webpack.config.renderer.dev.dll.babel.js
deleted file mode 100644
index 52d384474..000000000
--- a/configs/webpack.config.renderer.dev.dll.babel.js
+++ /dev/null
@@ -1,97 +0,0 @@
-/* eslint global-require: off, import/no-dynamic-require: off */
-
-/**
- * Builds the DLL for development electron renderer process
- */
-
-import webpack from 'webpack';
-import path from 'path';
-import merge from 'webpack-merge';
-import baseConfig from './webpack.config.base';
-import { dependencies } from '../package.json';
-// import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
-
-// CheckNodeEnv('development');
-
-const targetPlatform = 'electron-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
-
-const dist = path.join(__dirname, '..', 'dll');
-
-export default merge(baseConfig, {
- cache: false,
- context: path.join(__dirname, '..'),
-
- devtool: 'eval',
-
- mode: 'development',
-
- target: 'electron-renderer',
-
- externals: ['fsevents', 'crypto-browserify'],
-
- /**
- * Use `module` from `webpack.config.renderer.dev.js`
- */
- module: require('./webpack.config.renderer.dev.babel').default.module,
-
- entry: {
- renderer: Object.keys(dependencies || {}),
- },
-
- output: {
- library: 'renderer',
- path: dist,
- filename: '[name].dev.dll.js',
- libraryTarget: 'var',
- },
-
- plugins: [
- new webpack.DllPlugin({
- path: path.join(dist, '[name].json'),
- name: '[name]',
- }),
-
- /**
- * Create global constants which can be configured at compile time.
- *
- * Useful for allowing different behaviour between development builds and
- * release builds
- *
- * NODE_ENV should be production so that modules do not perform certain
- * development checks
- */
- new webpack.EnvironmentPlugin({
- NODE_ENV: 'development',
- }),
-
- /* new webpack.NormalModuleReplacementPlugin(
- /(.*)_PLATFORMIO_(\.*)/,
- resource => {
- resource.request = resource.request.replace(
- /_PLATFORMIO_/,
- `${targetPlatform}`
- );
- }
- ), */
-
- /* new webpack.NormalModuleReplacementPlugin(
- /(.*)_PDFDISTLIB_(\.*)/,
- resource => {
- resource.request = resource.request.replace(
- /_PDFDISTLIB_/,
- `pdfjs-dist/webpack`
- );
- }
- ), */
-
- new webpack.LoaderOptionsPlugin({
- debug: true,
- options: {
- context: path.join(__dirname, '..', 'app'),
- output: {
- path: path.join(__dirname, '..', 'dll'),
- },
- },
- }),
- ],
-});
diff --git a/configs/webpack.config.renderer.prod.babel.js b/configs/webpack.config.renderer.prod.babel.js
deleted file mode 100644
index 5c7777271..000000000
--- a/configs/webpack.config.renderer.prod.babel.js
+++ /dev/null
@@ -1,247 +0,0 @@
-/**
- * Build config for electron renderer process
- */
-
-import path from 'path';
-import webpack from 'webpack';
-import MiniCssExtractPlugin from 'mini-css-extract-plugin';
-import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
-import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer';
-import merge from 'webpack-merge';
-import baseConfig from './webpack.config.base';
-// import CheckNodeEnv from '../internals/scripts/CheckNodeEnv';
-
-const targetPlatform = 'electron-io'; // electron-io | webdav-io | cordova-io | process.env.APP_TARGET ||
-
-// CheckNodeEnv('production');
-export default merge(baseConfig, {
- devtool: 'source-map',
-
- mode: 'production',
-
- target: 'electron-renderer',
-
- entry: path.join(__dirname, '..', 'app/index'),
-
- output: {
- path: path.join(__dirname, '..', 'app/dist'),
- publicPath: './dist/',
- filename: 'renderer.prod.js',
- },
-
- module: {
- rules: [
- // Extract all .global.css to style.css as is
- {
- test: /\.global\.css$/,
- use: [
- {
- loader: MiniCssExtractPlugin.loader,
- options: {
- publicPath: './',
- },
- },
- {
- loader: 'css-loader',
- options: {
- sourceMap: true,
- },
- },
- ],
- },
- // Pipe other styles through css modules and append to style.css
- {
- test: /^((?!\.global).)*\.css$/,
- use: [
- {
- loader: MiniCssExtractPlugin.loader,
- },
- {
- loader: 'css-loader',
- options: {
- modules: {
- localIdentName: '[name]__[local]__[hash:base64:5]',
- },
- sourceMap: true,
- },
- },
- ],
- },
- // Add SASS support - compile all .global.scss files and pipe it to style.css
- {
- test: /\.global\.(scss|sass)$/,
- use: [
- {
- loader: MiniCssExtractPlugin.loader,
- },
- {
- loader: 'css-loader',
- options: {
- sourceMap: true,
- importLoaders: 1,
- },
- },
- {
- loader: 'sass-loader',
- options: {
- sourceMap: true,
- },
- },
- ],
- },
- // Add SASS support - compile all other .scss files and pipe it to style.css
- {
- test: /^((?!\.global).)*\.(scss|sass)$/,
- use: [
- {
- loader: MiniCssExtractPlugin.loader,
- },
- {
- loader: 'css-loader',
- options: {
- modules: {
- localIdentName: '[name]__[local]__[hash:base64:5]',
- },
- importLoaders: 1,
- sourceMap: true,
- },
- },
- {
- loader: 'sass-loader',
- options: {
- sourceMap: true,
- },
- },
- ],
- },
- // WOFF Font
- {
- test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
- use: {
- loader: 'url-loader',
- options: {
- limit: 10000,
- mimetype: 'application/font-woff',
- },
- },
- type: 'javascript/auto',
- },
- // WOFF2 Font
- {
- test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
- use: {
- loader: 'url-loader',
- options: {
- limit: 10000,
- mimetype: 'application/font-woff',
- },
- },
- type: 'javascript/auto',
- },
- // TTF Font
- {
- test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
- use: {
- loader: 'url-loader',
- options: {
- limit: 10000,
- mimetype: 'application/octet-stream',
- },
- },
- type: 'javascript/auto',
- },
- // EOT Font
- {
- test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
- use: 'file-loader',
- type: 'javascript/auto',
- },
- // SVG Font
- {
- test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
- use: {
- loader: 'url-loader',
- options: {
- limit: 10000,
- mimetype: 'image/svg+xml',
- },
- },
- type: 'javascript/auto',
- },
- // Text files
- {
- test: /\.(txt)$/,
- use: 'raw-loader',
- type: 'javascript/auto',
- },
- // Common Image Formats
- {
- test: /\.(?:ico|gif|png|jpg|jpeg|webp)$/,
- type: 'asset/resource',
- },
- ],
- },
-
- optimization: {
- minimizer: process.env.E2E_BUILD
- ? []
- : [
- // For webpack@5 you can use the `...` syntax to extend existing minimizers (i.e. `terser-webpack-plugin`), uncomment the next line
- `...`,
- new CssMinimizerPlugin(),
- /*new OptimizeCSSAssetsPlugin({
- cssProcessorOptions: {
- map: {
- inline: false,
- annotation: true
- }
- }
- })*/
- ],
- },
-
- plugins: [
- /**
- * Create global constants which can be configured at compile time.
- *
- * Useful for allowing different behaviour between development builds and
- * release builds
- *
- * NODE_ENV should be production so that modules do not perform certain
- * development checks
- */
- new webpack.EnvironmentPlugin({
- NODE_ENV: 'production',
- }),
-
- /* new webpack.NormalModuleReplacementPlugin(
- /(.*)_PLATFORMIO_(\.*)/,
- resource => {
- resource.request = resource.request.replace(
- /_PLATFORMIO_/,
- `${targetPlatform}`
- );
- }
- ), */
-
- /* new webpack.NormalModuleReplacementPlugin(
- /(.*)_PDFDISTLIB_(\.*)/,
- resource => {
- resource.request = resource.request.replace(
- /_PDFDISTLIB_/,
- `pdfjs-dist/webpack`
- );
- }
- ), */
-
- new MiniCssExtractPlugin({
- filename: 'style.css',
- }),
-
- new BundleAnalyzerPlugin({
- analyzerMode:
- process.env.OPEN_ANALYZER === 'true' ? 'server' : 'disabled',
- openAnalyzer: process.env.OPEN_ANALYZER === 'true',
- }),
- ],
-});
diff --git a/scripts/genswconf.js b/scripts/genswconf.js
index 7de96852b..340930c7e 100644
--- a/scripts/genswconf.js
+++ b/scripts/genswconf.js
@@ -1,5 +1,5 @@
const sh = require('shelljs');
-const { version } = require('../app/package.json');
+const { version } = require('../release/app/package.json');
const FILES_TO_CACHE = ['offline.html'];