-
Notifications
You must be signed in to change notification settings - Fork 20
/
webpack.prod.js
58 lines (49 loc) · 1.18 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
53
54
55
56
57
58
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = {
mode: 'production',
devtool: 'source-map',
entry: {
bundle: './src/js/index.js',
worker: './src/js/worker.js',
},
output: {
filename: '[name].js',
sourceMapFilename: '[name].map',
path: path.join(__dirname, '/build'),
},
module: {
rules: [
{
test: /.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['@babel/preset-react'],
}
},
],
},
optimization: {
minimizer: [
new TerserPlugin({
exclude: /\.min\.js$/gi,
sourceMap: true,
parallel: true,
}),
],
},
plugins: [
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.ModuleConcatenationPlugin(),
new CopyWebpackPlugin([
{ from: './src/*.html', to: './[name].[ext]' },
{ from: './src/*.css', to: './[name].[ext]' },
{ from: './src/img/**.*', to: './img/[name].[ext]' },
]),
]
};