-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.prod.js
43 lines (42 loc) · 1.14 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
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
module.exports = {
mode: 'production',
devtool: 'cheap-source-map',
entry: { app: './src/index.tsx' },
output: {
path: `${__dirname}/dist`,
publicPath: '/',
filename: '[name].js',
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
new HtmlWebpackPlugin({
template: `${__dirname}/public/index.html`,
filename: 'index.html',
favicon: 'public/favicon.ico'
}),
new CopyPlugin([
{ from: `${__dirname}/public/404.html`, to: '404.html' },
{ from: `${__dirname}/public/CNAME`, to: 'CNAME', toType: 'file' },
])
],
optimization: {
runtimeChunk: { name: 'app' },
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const pkg = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return `npm.${pkg.replace('@', '')}`;
},
},
},
},
},
};