|
@@ -14,6 +14,7 @@ const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
|
|
|
const env = require('../config/prod.env')
|
|
const env = require('../config/prod.env')
|
|
|
|
|
|
|
|
const webpackConfig = merge(baseWebpackConfig, {
|
|
const webpackConfig = merge(baseWebpackConfig, {
|
|
|
|
|
+ mode: 'production',
|
|
|
module: {
|
|
module: {
|
|
|
rules: utils.styleLoaders({
|
|
rules: utils.styleLoaders({
|
|
|
sourceMap: config.build.productionSourceMap,
|
|
sourceMap: config.build.productionSourceMap,
|
|
@@ -42,26 +43,45 @@ const webpackConfig = merge(baseWebpackConfig, {
|
|
|
test: /[\\/]src[\\/]/,
|
|
test: /[\\/]src[\\/]/,
|
|
|
priority: -20,
|
|
priority: -20,
|
|
|
chunks: 'initial'
|
|
chunks: 'initial'
|
|
|
|
|
+ },
|
|
|
|
|
+ commons: {
|
|
|
|
|
+ name: 'commons',
|
|
|
|
|
+ minChunks: 2,
|
|
|
|
|
+ priority: -30,
|
|
|
|
|
+ chunks: 'initial',
|
|
|
|
|
+ reuseExistingChunk: true
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
runtimeChunk: {
|
|
runtimeChunk: {
|
|
|
name: 'manifest'
|
|
name: 'manifest'
|
|
|
|
|
+ },
|
|
|
|
|
+ minimizer: [
|
|
|
|
|
+ new UglifyJsPlugin({
|
|
|
|
|
+ uglifyOptions: {
|
|
|
|
|
+ compress: {
|
|
|
|
|
+ warnings: false,
|
|
|
|
|
+ drop_console: true,
|
|
|
|
|
+ drop_debugger: true
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ sourceMap: config.build.productionSourceMap,
|
|
|
|
|
+ parallel: true
|
|
|
|
|
+ })
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ performance: {
|
|
|
|
|
+ hints: 'warning',
|
|
|
|
|
+ maxAssetSize: 1024000,
|
|
|
|
|
+ maxEntrypointSize: 2048000,
|
|
|
|
|
+ assetFilter: function (assetFilename) {
|
|
|
|
|
+ return assetFilename.endsWith('.js') || assetFilename.endsWith('.css')
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
plugins: [
|
|
plugins: [
|
|
|
new webpack.DefinePlugin({
|
|
new webpack.DefinePlugin({
|
|
|
'process.env': env
|
|
'process.env': env
|
|
|
}),
|
|
}),
|
|
|
- new UglifyJsPlugin({
|
|
|
|
|
- uglifyOptions: {
|
|
|
|
|
- compress: {
|
|
|
|
|
- warnings: false
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
- sourceMap: config.build.productionSourceMap,
|
|
|
|
|
- parallel: true
|
|
|
|
|
- }),
|
|
|
|
|
new ExtractTextPlugin({
|
|
new ExtractTextPlugin({
|
|
|
filename: utils.assetsPath('css/[name].[hash].css'),
|
|
filename: utils.assetsPath('css/[name].[hash].css'),
|
|
|
allChunks: true,
|
|
allChunks: true,
|
|
@@ -78,7 +98,9 @@ const webpackConfig = merge(baseWebpackConfig, {
|
|
|
minify: {
|
|
minify: {
|
|
|
removeComments: true,
|
|
removeComments: true,
|
|
|
collapseWhitespace: true,
|
|
collapseWhitespace: true,
|
|
|
- removeAttributeQuotes: true
|
|
|
|
|
|
|
+ removeAttributeQuotes: true,
|
|
|
|
|
+ minifyCSS: true,
|
|
|
|
|
+ minifyJS: true
|
|
|
},
|
|
},
|
|
|
chunksSortMode: 'auto'
|
|
chunksSortMode: 'auto'
|
|
|
}),
|
|
}),
|