-
Notifications
You must be signed in to change notification settings - Fork 35
/
webpack.prod.mjs
54 lines (51 loc) · 1.35 KB
/
webpack.prod.mjs
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
53
54
// Import External Dependencies
import { merge } from 'webpack-merge';
import CssMinimizerPlugin from 'css-minimizer-webpack-plugin';
import { InjectManifest } from 'workbox-webpack-plugin';
import path from 'path';
// Load Common Configuration
import common from './webpack.common.mjs';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import ProdAssetsManifest from './src/ProdAssetsManifest.mjs';
export default (env) =>
merge(common(env), {
mode: 'production',
entry: {
index: {
import: './index.jsx',
filename: 'index.[contenthash].js',
},
},
output: {
filename: '[name].[contenthash].js'
},
optimization: {
splitChunks: {
cacheGroups: {
vendors: {
test: /node_modules/,
chunks: 'initial',
enforce: true,
filename: 'vendor.[contenthash].js',
},
},
},
minimizer: [
'...',
new CssMinimizerPlugin({
minify: CssMinimizerPlugin.lightningCssMinify,
}),
],
},
plugins: [
new InjectManifest({
swSrc: path.join(__dirname, 'src/sw.js'),
swDest: 'sw.js',
// exclude license
exclude: [/license\.txt/i],
}),
new ProdAssetsManifest(),
],
});