-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.prod.js
55 lines (53 loc) · 1.38 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
const path = require('path');
// const CompressionPlugin = require('compression-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
let entry;
let sourceMap = false;
let devtool = false;
let minimize = false;
if (process.env.MIN_POLIPOP === '0') {
entry = {
polipop: './src/index.js',
};
} else if (process.env.MIN_POLIPOP === '1') {
entry = {
'polipop.min': './src/index.js',
};
sourceMap = false; // Set true to generate source maps for minified files.
devtool = sourceMap ? 'source-map' : false;
minimize = true;
}
module.exports = {
mode: 'production',
entry: entry,
devtool: devtool,
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|docs)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
},
},
},
],
},
// plugins: [new CompressionPlugin()],
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist'),
library: {
name: 'Polipop',
type: 'umd',
export: 'default',
},
globalObject: 'this',
},
optimization: {
minimize: minimize,
minimizer: [new TerserPlugin()],
},
};