/
webpack.config.prod.js
44 lines (42 loc) · 1.24 KB
/
webpack.config.prod.js
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
34
35
36
37
38
39
40
41
42
43
44
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const BundleAnalyzerPlugin =
require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
const config = require('./webpack.config.js');
const TerserPlugin = require('terser-webpack-plugin');
const path = require('path');
const { execSync } = require('child_process');
const gitCommitSHA = () => {
try {
const commitSHA = execSync('git rev-parse HEAD').toString().trim();
return { 'process.env.COMMIT_SHA': JSON.stringify(commitSHA) };
} catch (_) {
return {};
}
};
module.exports = webpackMerge.smart(config, {
mode: 'production',
output: {
filename: `[chunkhash]/graun.standalone.commercial.js`,
chunkFilename: `[chunkhash]/graun.[name].commercial.js`,
path: path.join(__dirname, 'dist', 'bundle', 'prod'),
clean: true,
},
devtool: 'source-map',
plugins: [
new BundleAnalyzerPlugin({
reportFilename: './commercial-bundle-analyzer-report.html',
analyzerMode: 'static',
openAnalyzer: false,
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.OVERRIDE_BUNDLE_PATH': JSON.stringify(false),
...gitCommitSHA(),
}),
],
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
});