Skip to content

Commit

Permalink
chore: webpack perf config from common to prod
Browse files Browse the repository at this point in the history
  • Loading branch information
joriewong authored and joriewong committed Mar 24, 2021
1 parent 809559b commit 27e4c96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
14 changes: 1 addition & 13 deletions build/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ const webpack = require('webpack')
const { srcPath } = require('./myPath')

const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')

module.exports = {
entry: {
Expand Down Expand Up @@ -55,15 +53,5 @@ module.exports = {
new MiniCssExtractPlugin({
filename: 'css/main.css',
}),
],
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin(),
],
},
]
}
12 changes: 12 additions & 0 deletions build/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ const CommonConf = require('./webpack.common')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const { distPath } = require('./myPath')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin')

// 包体积分析
const isAnalyzer = process.env.NODE_ENV === 'production_analyzer'
Expand All @@ -29,4 +31,14 @@ module.exports = smart(CommonConf, {
},
plugins,
devtool: 'source-map',
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin(),
],
},
})

0 comments on commit 27e4c96

Please sign in to comment.