|
@@ -2,11 +2,11 @@ const fs = require('fs');
|
|
const path = require('path')
|
|
const path = require('path')
|
|
const webpack = require('webpack')
|
|
const webpack = require('webpack')
|
|
const createThemeColorReplacerPlugin = require('./config/plugin.config')
|
|
const createThemeColorReplacerPlugin = require('./config/plugin.config')
|
|
-
|
|
+
|
|
const compressionWebpackPlugin = require('compression-webpack-plugin');
|
|
const compressionWebpackPlugin = require('compression-webpack-plugin');
|
|
-
|
|
+
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
-
|
|
+
|
|
const WebpackVersionPlugin = require('webpack-version-plugin');
|
|
const WebpackVersionPlugin = require('webpack-version-plugin');
|
|
const versionConfig = require(resolve('public/version.json'));
|
|
const versionConfig = require(resolve('public/version.json'));
|
|
|
|
|
|
@@ -22,13 +22,13 @@ function isProd () {
|
|
return process.env.NODE_ENV === 'production'
|
|
return process.env.NODE_ENV === 'production'
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
-
|
|
+
|
|
const BASE_URL = isProd ? '/' : '/'
|
|
const BASE_URL = isProd ? '/' : '/'
|
|
|
|
|
|
const assetsCDN = {
|
|
const assetsCDN = {
|
|
@@ -61,21 +61,21 @@ const prodExternals = {
|
|
|
|
|
|
|
|
|
|
const vueConfig = {
|
|
const vueConfig = {
|
|
- runtimeCompiler: true,
|
|
+ runtimeCompiler: true,
|
|
publicPath: BASE_URL,
|
|
publicPath: BASE_URL,
|
|
configureWebpack: {
|
|
configureWebpack: {
|
|
optimization: isProd() ? {
|
|
optimization: isProd() ? {
|
|
minimize: true,
|
|
minimize: true,
|
|
minimizer: [new TerserPlugin({
|
|
minimizer: [new TerserPlugin({
|
|
- test: /\.js(\?.*)?$/i,
|
|
+ test: /\.js(\?.*)?$/i,
|
|
- parallel: true,
|
|
+ parallel: true,
|
|
- terserOptions: {
|
|
+ terserOptions: {
|
|
output:{comments: false},
|
|
output:{comments: false},
|
|
- compress: {
|
|
+ compress: {
|
|
pure_funcs: ["console.log"]
|
|
pure_funcs: ["console.log"]
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- extractComments: true,
|
|
+ extractComments: true,
|
|
})],
|
|
})],
|
|
}:{},
|
|
}:{},
|
|
|
|
|
|
@@ -83,15 +83,15 @@ const vueConfig = {
|
|
|
|
|
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
|
new compressionWebpackPlugin({
|
|
new compressionWebpackPlugin({
|
|
-
|
|
+
|
|
- filename: '[path].gz[query]',
|
|
+ filename: '[path].gz[query]',
|
|
-
|
|
+
|
|
algorithm: 'gzip',
|
|
algorithm: 'gzip',
|
|
-
|
|
+
|
|
test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
|
|
test: new RegExp('\\.(' + ['js', 'css'].join('|') + ')$'),
|
|
-
|
|
+
|
|
threshold: 10240,
|
|
threshold: 10240,
|
|
-
|
|
+
|
|
minRatio: 0.8
|
|
minRatio: 0.8
|
|
}),
|
|
}),
|
|
new WebpackVersionPlugin({
|
|
new WebpackVersionPlugin({
|
|
@@ -137,17 +137,17 @@ const vueConfig = {
|
|
}
|
|
}
|
|
|
|
|
|
config.optimization && config.optimization.splitChunks({
|
|
config.optimization && config.optimization.splitChunks({
|
|
-
|
|
+
|
|
- chunks: 'all',
|
|
+ chunks: 'all',
|
|
- minSize: 30000,
|
|
+ minSize: 30000,
|
|
- maxSize: 0,
|
|
+ maxSize: 0,
|
|
- minChunks: 1,
|
|
+ minChunks: 1,
|
|
- maxAsyncRequests: 5,
|
|
+ maxAsyncRequests: 5,
|
|
- maxInitialRequests: 4,
|
|
+ maxInitialRequests: 4,
|
|
- automaticNameDelimiter: '~',
|
|
+ automaticNameDelimiter: '~',
|
|
name: true,
|
|
name: true,
|
|
cacheGroups: {
|
|
cacheGroups: {
|
|
-
|
|
+
|
|
vendors: {
|
|
vendors: {
|
|
test: /[\\/]node_modules[\\/]/,
|
|
test: /[\\/]node_modules[\\/]/,
|
|
name: 'chunk-vendors',
|
|
name: 'chunk-vendors',
|
|
@@ -158,7 +158,7 @@ const vueConfig = {
|
|
chunks: 'all',
|
|
chunks: 'all',
|
|
priority: -10,
|
|
priority: -10,
|
|
},
|
|
},
|
|
-
|
|
+
|
|
antDesign: {
|
|
antDesign: {
|
|
name: 'chunk-antDesign',
|
|
name: 'chunk-antDesign',
|
|
priority: 19,
|
|
priority: 19,
|
|
@@ -169,18 +169,18 @@ const vueConfig = {
|
|
priority: 20,
|
|
priority: 20,
|
|
test: /[\\/]node_modules[\\/]_?ant-design-vue(.*)/
|
|
test: /[\\/]node_modules[\\/]_?ant-design-vue(.*)/
|
|
},
|
|
},
|
|
-
|
|
+
|
|
common: {
|
|
common: {
|
|
name: 'chunk-common',
|
|
name: 'chunk-common',
|
|
minChunks: 2,
|
|
minChunks: 2,
|
|
- maxSize: 1024,
|
|
+ maxSize: 1024,
|
|
priority: -20,
|
|
priority: -20,
|
|
reuseExistingChunk: true
|
|
reuseExistingChunk: true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
-
|
|
+
|
|
if (process.env.npm_config_report) {
|
|
if (process.env.npm_config_report) {
|
|
config.plugin('webpack-bundle-analyzer')
|
|
config.plugin('webpack-bundle-analyzer')
|
|
.use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
|
|
.use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin)
|
|
@@ -193,7 +193,7 @@ const vueConfig = {
|
|
loaderOptions: {
|
|
loaderOptions: {
|
|
less: {
|
|
less: {
|
|
modifyVars: {
|
|
modifyVars: {
|
|
-
|
|
+
|
|
'primary-color': process.env.VUE_APP_THEME_COLOR,
|
|
'primary-color': process.env.VUE_APP_THEME_COLOR,
|
|
'link-color': process.env.VUE_APP_THEME_COLOR
|
|
'link-color': process.env.VUE_APP_THEME_COLOR
|
|
|
|
|