diff options
Diffstat (limited to 'electron/service/config')
| -rw-r--r-- | electron/service/config/base.js | 126 | ||||
| -rw-r--r-- | electron/service/config/css.js | 72 | ||||
| -rw-r--r-- | electron/service/config/dev.js | 43 | ||||
| -rw-r--r-- | electron/service/config/main.js | 73 | ||||
| -rw-r--r-- | electron/service/config/prod.js | 41 | ||||
| -rw-r--r-- | electron/service/config/renderer.js | 45 | ||||
| -rw-r--r-- | electron/service/config/terserOptions.js | 42 |
7 files changed, 0 insertions, 442 deletions
diff --git a/electron/service/config/base.js b/electron/service/config/base.js deleted file mode 100644 index a3132904..00000000 --- a/electron/service/config/base.js +++ /dev/null @@ -1,126 +0,0 @@ -'use strict' - -const { DefinePlugin, EnvironmentPlugin } = require('webpack') -const { VueLoaderPlugin } = require('vue-loader') -const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin') -const HTMLPlugin = require('html-webpack-plugin') -const { VuetifyPlugin } = require('webpack-plugin-vuetify') - -const resolveClientEnv = require('../utils/resolveClientEnv') -const paths = require('../utils/paths') - -const config = require('../project.config') - -const isProd = process.env.NODE_ENV === 'production' - -module.exports = { - context: process.cwd(), - - output: { - path: paths.resolve(config.outputDir), - publicPath: config.dev.publicPath, - filename: '[name].js', - }, - - resolve: { - alias: { - '@': paths.resolve('src'), - }, - extensions: ['.ts', '.tsx', '.js', '.jsx', '.vue', '.json', '.html', '.ejs'], - }, - - plugins: [ - new VueLoaderPlugin(), - new EnvironmentPlugin(['NODE_ENV']), - new CaseSensitivePathsPlugin(), - new HTMLPlugin({ - template: paths.resolve('src/index.html'), - templateParameters: { - ...resolveClientEnv( - { publicPath: isProd ? config.build.publicPath : config.dev.publicPath }, - false /* raw */ - ), - }, - }), - new VuetifyPlugin({ autoImport: true }), - new DefinePlugin({ - // vue3 feature flags <http://link.vuejs.org/feature-flags> - __VUE_OPTIONS_API__: 'true', - __VUE_PROD_DEVTOOLS__: 'false', - - ...resolveClientEnv({ - publicPath: isProd ? config.build.publicPath : config.dev.publicPath, - }), - }), - ], - - module: { - noParse: /^(vue|vue-router)$/, - - rules: [ - { - test: /\.vue$/, - loader: 'vue-loader', - }, - // babel - { - test: /\.m?jsx?$/, - exclude: (file) => { - // always transpile js in vue files - if (/\.vue\.jsx?$/.test(file)) { - return false - } - // Don't transpile node_modules - return /node_modules/.test(file) - }, - use: ['thread-loader', 'babel-loader'], - }, - - // ts - { - test: /\.tsx?$/, - use: [ - 'thread-loader', - 'babel-loader', - { - loader: 'ts-loader', - options: { - transpileOnly: true, - appendTsSuffixTo: ['\\.vue$'], - happyPackMode: true, - }, - }, - ], - }, - - // images - { - test: /\.(png|jpe?g|gif|webp)(\?.*)?$/, - type: 'asset', - generator: { filename: 'img/[contenthash:8][ext][query]' }, - }, - - // do not base64-inline SVGs. - // https://github.com/facebookincubator/create-react-app/pull/1180 - { - test: /\.(svg)(\?.*)?$/, - type: 'asset/resource', - generator: { filename: 'img/[contenthash:8][ext][query]' }, - }, - - // media - { - test: /\.(mp4|webm|ogg|mp3|wav|flac|aac)(\?.*)?$/, - type: 'asset', - generator: { filename: 'media/[contenthash:8][ext][query]' }, - }, - - // fonts - { - test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/i, - type: 'asset', - generator: { filename: 'fonts/[contenthash:8][ext][query]' }, - }, - ], - }, -} diff --git a/electron/service/config/css.js b/electron/service/config/css.js deleted file mode 100644 index 3fb5893e..00000000 --- a/electron/service/config/css.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict' - -const MiniCssExtractPlugin = require('mini-css-extract-plugin') - -const isProd = process.env.NODE_ENV === 'production' - -const plugins = [] -if (isProd) { - const filename = 'css/[name].[contenthash:8].css' - - plugins.push( - new MiniCssExtractPlugin({ - filename, - chunkFilename: filename, - }) - ) -} - -const genStyleRules = () => { - const cssLoader = { - loader: 'css-loader', - options: { - // how many loaders before css-loader should be applied to [@import]ed resources. - // stylePostLoader injected by vue-loader + postcss-loader - importLoaders: 1 + 1, - esModule: false, // css-loader using ES Modules as default in v4, but vue-style-loader support cjs only. - }, - } - const postcssLoader = { - loader: 'postcss-loader', - options: { - postcssOptions: { - plugins: [require('autoprefixer')] - }, - }, - } - const extractPluginLoader = { - loader: MiniCssExtractPlugin.loader, - } - const vueStyleLoader = { - loader: 'vue-style-loader', - } - - function createCSSRule(test, loader, loaderOptions) { - const loaders = [cssLoader, postcssLoader] - - if (isProd) { - loaders.unshift(extractPluginLoader) - } else { - loaders.unshift(vueStyleLoader) - } - - if (loader) { - loaders.push({ loader, options: loaderOptions }) - } - - return { test, use: loaders } - } - - return [ - createCSSRule(/\.css$/), - createCSSRule(/\.p(ost)?css$/), - createCSSRule(/\.scss$/, 'sass-loader') - ] -} - -module.exports = { - plugins, - module: { - rules: genStyleRules(), - }, -} diff --git a/electron/service/config/dev.js b/electron/service/config/dev.js deleted file mode 100644 index 42a82b37..00000000 --- a/electron/service/config/dev.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict' - -const { merge } = require('webpack-merge') - -const baseWebpackConfig = require('./base') -const cssWebpackConfig = require('./css') -const config = require('../project.config') -const { ProvidePlugin, DefinePlugin } = require('webpack') - - -module.exports = merge(baseWebpackConfig, cssWebpackConfig, { - entry: { - main: './src/renderer/main.js' - }, - - mode: 'development', - - devtool: 'eval-cheap-module-source-map', - - devServer: { - watchFiles: ['src/**/*'], - historyApiFallback: { - rewrites: [{ from: /./, to: '/index.html' }], - }, - devMiddleware: { - publicPath: config.dev.publicPath, - }, - open: false, - host: '0.0.0.0', - port: 'auto', - liveReload: true, - }, - - infrastructureLogging: { - level: 'warn', - }, - - stats: { - assets: false, - modules: false, - errorDetails: false, - }, -}) diff --git a/electron/service/config/main.js b/electron/service/config/main.js deleted file mode 100644 index 3083dea0..00000000 --- a/electron/service/config/main.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict' - -const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin') -const config = require('../project.config') - -const resolveClientEnv = require('../utils/resolveClientEnv') -const paths = require('../utils/paths') -const { merge } = require('webpack-merge') -const TerserPlugin = require('terser-webpack-plugin') -const cssWebpackConfig = require('./css') -const terserOptions = require('./terserOptions') -const isProd = process.env.NODE_ENV === 'production' - -module.exports = merge(cssWebpackConfig, { - context: process.cwd(), - mode: 'production', - entry: { - main: './src/main/index.js', - preload: './src/main/preload.js', - }, - - node: { - __dirname: false, - }, - - optimization: { - minimize: true, - minimizer: [new TerserPlugin(terserOptions())], - moduleIds: 'named', - }, - target: ['electron-main'], - - output: { - path: paths.resolve(config.outputDir), - publicPath: config.dev.publicPath, - filename: '[name].js', - }, - - resolve: { - alias: { - '@': paths.resolve('src'), - }, - extensions: ['.ts', '.tsx', '.js', '.jsx', '.vue', '.json', 'html', 'ejs'], - }, - - plugins: [ - new CaseSensitivePathsPlugin(), - ], - - module: { - noParse: /^(vue|vue-router)$/, - - rules: [ - // ts - { - test: /\.tsx?$/, - use: [ - 'thread-loader', - 'babel-loader', - { - loader: 'ts-loader', - options: { - transpileOnly: true, - appendTsSuffixTo: ['\\.vue$'], - happyPackMode: true, - }, - }, - ], - }, - ], - }, -} -)
\ No newline at end of file diff --git a/electron/service/config/prod.js b/electron/service/config/prod.js deleted file mode 100644 index 1d9e8726..00000000 --- a/electron/service/config/prod.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict' - -const { merge } = require('webpack-merge') -const TerserPlugin = require('terser-webpack-plugin') - -const baseWebpackConfig = require('./base') -const cssWebpackConfig = require('./css') -const config = require('../project.config') -const terserOptions = require('./terserOptions') - -module.exports = merge(baseWebpackConfig, cssWebpackConfig, { - mode: 'production', - - output: { - publicPath: config.build.publicPath, - }, - - optimization: { - minimize: true, - minimizer: [new TerserPlugin(terserOptions())], - moduleIds: 'deterministic', - moduleIds: 'named', - splitChunks: { - cacheGroups: { - defaultVendors: { - name: `chunk-vendors`, - test: /[\\/]node_modules[\\/]/, - priority: -10, - chunks: 'initial', - }, - common: { - name: `chunk-common`, - minChunks: 2, - priority: -20, - chunks: 'initial', - reuseExistingChunk: true, - }, - }, - }, - }, -}) diff --git a/electron/service/config/renderer.js b/electron/service/config/renderer.js deleted file mode 100644 index cf3fab01..00000000 --- a/electron/service/config/renderer.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict' - -const { merge } = require('webpack-merge') -const TerserPlugin = require('terser-webpack-plugin') - -const baseWebpackConfig = require('./base') -const cssWebpackConfig = require('./css') -const config = require('../project.config') -const terserOptions = require('./terserOptions') - -module.exports = merge(baseWebpackConfig, cssWebpackConfig, { - mode: 'production', - entry: { - renderer: './src/renderer/main.js', - }, - - output: { - publicPath: config.build.publicPath, - }, - - optimization: { - minimize: true, - minimizer: [new TerserPlugin(terserOptions())], - moduleIds: 'deterministic', - moduleIds: 'named', - splitChunks: { - cacheGroups: { - defaultVendors: { - name: `chunk-vendors`, - test: /[\\/]node_modules[\\/]/, - priority: -10, - chunks: 'initial', - }, - common: { - name: `chunk-common`, - minChunks: 2, - priority: -20, - chunks: 'initial', - reuseExistingChunk: true, - }, - }, - }, - }, - target: ['electron-renderer'], -}) diff --git a/electron/service/config/terserOptions.js b/electron/service/config/terserOptions.js deleted file mode 100644 index 134a3258..00000000 --- a/electron/service/config/terserOptions.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict' - -module.exports = (options) => ({ - terserOptions: { - compress: { - // turn off flags with small gains to speed up minification - arrows: false, - collapse_vars: false, // 0.3kb - comparisons: false, - computed_props: false, - hoist_funs: false, - hoist_props: false, - hoist_vars: false, - inline: false, - loops: false, - negate_iife: false, - properties: false, - reduce_funcs: false, - reduce_vars: false, - switches: false, - toplevel: false, - typeofs: false, - - // a few flags with noticable gains/speed ratio - // numbers based on out of the box vendor bundle - booleans: true, // 0.7kb - if_return: true, // 0.4kb - sequences: true, // 0.7kb - unused: true, // 2.3kb - - // required features to drop conditional branches - conditionals: true, - dead_code: true, - evaluate: true, - }, - mangle: { - safari10: true, - }, - }, - // parallel: options.parallel, - extractComments: false, -}) |
