-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathwebpack.prod.js
39 lines (38 loc) · 1.19 KB
/
webpack.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
const path = require('path');
const webpack = require('webpack');
const WebpackShellPlugin = require('webpack-shell-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin')
const merge = require('webpack-merge');
const common = require('./webpack.common.js');
const options = merge(common, {
mode: 'production',
devtool: 'source-map',
optimization: {
splitChunks: {
cacheGroups: {
vendor: { // 将第三方模块提取出来
test: /[\\/]node_modules[\\/]/,
chunks: 'initial',
name: 'vendor'
}
}
},
runtimeChunk: {name: 'runtime'}
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new HtmlWebpackPlugin({
title: 'Popup',
template: './popup/index.html',
inject: true,
chunks: ['runtime', 'vendor','popup'],
filename: 'popup.html'
}),
new WebpackShellPlugin({
onBuildEnd: ['node scripts/remove-evals.js', 'node scripts/build-zip.js']
})
]
});
module.exports = options;