forked from docschina/webpack.js.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.prod.js
52 lines (50 loc) · 1.09 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
40
41
42
43
44
45
46
47
48
49
50
51
52
// Import External Dependencies
const { merge } = require('webpack-merge');
const OptimizeCSSAssetsPlugin = require('css-minimizer-webpack-plugin');
const { InjectManifest } = require('workbox-webpack-plugin');
const path = require('path');
// Load Common Configuration
const common = require('./webpack.common.js');
module.exports = env => merge(common(env), {
mode: 'production',
cache: {
buildDependencies: {
config: [__filename],
}
},
entry: {
index: {
import: './index.jsx',
filename: 'index.bundle.js'
}
},
output: {
filename: '[name].[contenthash].js'
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
test: /node_modules/,
chunks: 'initial',
enforce: true,
filename: 'vendor.bundle.js'
}
}
},
minimizer: [
'...',
new OptimizeCSSAssetsPlugin({})
]
},
plugins: [
new InjectManifest({
swSrc: path.join(__dirname, 'src/sw.js'),
swDest: 'sw.js',
// exclude license
exclude: [
/license\.txt/i
]
})
]
});