-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.production.cjs
32 lines (30 loc) · 1.02 KB
/
webpack.production.cjs
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
const { join } = require('path');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const CompressionWebpackPlugin = require('compression-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const webpack = require('webpack');
const IS_DEPLOYMENT = process.env.NODE_ENV === 'deployment';
/** Webpack production environment options */
module.exports = {
mode: 'production',
output: {
filename: '[name].[fullhash].bundle.js',
chunkFilename: '[name].[fullhash].bundle.js',
pathinfo: false
},
devtool: !IS_DEPLOYMENT ? 'source-map' : false,
plugins: [
new CopyWebpackPlugin({
patterns: [{ from: join(__dirname, 'robots.txt') }]
}),
...(!IS_DEPLOYMENT
? [new webpack.SourceMapDevToolPlugin({ filename: 'debug/[file].map' })]
: [new CompressionWebpackPlugin({ threshold: 860 })]),
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
statsFilename: 'reports/bundles.json',
logLevel: 'error'
})
]
};