-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwebpack.config.prod.babel.js
More file actions
33 lines (29 loc) · 992 Bytes
/
webpack.config.prod.babel.js
File metadata and controls
33 lines (29 loc) · 992 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import path from 'path'
import webpack from 'webpack'
import merge from 'webpack-merge' // Merges webpack configurations
import { CleanWebpackPlugin } from 'clean-webpack-plugin' // Cleans build directory before building assets
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin' // Minimize css files
import TerserPlugin from 'terser-webpack-plugin' // Minimize js files
import baseWebpackConfig from './webpack.config.base.babel.js'
const resolveRootPath = (p) => path.resolve(__dirname, p)
module.exports = (env) => {
return merge(
baseWebpackConfig,
{
mode: 'production',
devtool: 'nosources-source-map',
optimization: {
minimizer: [
new TerserPlugin(),
new CssMinimizerPlugin()
]
},
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: [resolveRootPath('build')]
}),
new webpack.optimize.AggressiveMergingPlugin() // merge chunks
]
}
)
}