-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.prod.js
67 lines (63 loc) · 1.41 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
59
60
61
62
63
64
65
66
67
/* eslint import/no-extraneous-dependencies: ["error", {devDependencies: true}] */
const path = require('path');
const merge = require('webpack-merge');
const TerserPlugin = require('terser-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const common = require('./webpack.common');
const reactExternal = {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react',
};
const reactDOMExternal = {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom',
};
module.exports = merge(common, {
entry: {
'react-flaggables': './src/index.js',
'react-flaggables.min': './src/index.js',
},
externals: {
react: reactExternal,
'react-dom': reactDOMExternal,
},
output: {
filename: '[name].js',
chunkFilename: '[id].chunk.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
libraryTarget: 'umd',
library: 'ReactFlaggables',
},
mode: 'production',
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
},
},
],
},
plugins: [
new BundleAnalyzerPlugin({
analyzerMode: 'static',
openAnalyzer: false,
defaultSizes: 'gzip',
}),
],
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
}),
],
},
});