-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.prod.js
58 lines (57 loc) · 1.66 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
const path = require("path");
const webpack = require("webpack");
const CompressionPlugin = require('compression-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');
module.exports = {
entry: [
"babel-polyfill",
"./src/index"
],
output: {
path: path.join(__dirname, "deploy/dist/"),
filename: "bundle.js",
publicPath: "dist/"
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify("production")
/* we don't need to define env.PERF in production as babel strips out the function calls :) */
}
}),
/* Note: console.log statements are not stripped out */
new webpack.optimize.AggressiveMergingPlugin(), // merge chunks - https://github.com/webpack/docs/wiki/list-of-plugins#aggressivemergingplugin
new CompressionPlugin({ // gzip everything - https://github.com/webpack-contrib/compression-webpack-plugin
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8
}),
new WebpackShellPlugin({
onBuildStart: ['mkdir -p deploy/dist deploy/data'],
onBuildEnd: ["./bin/postbuild.sh"]
})
],
optimization: {
minimizer: [new TerserPlugin()]},
module: {
rules: [
{
test: /\.js$/,
use: ["babel-loader"],
include: path.join(__dirname, "src")
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.(gif|png|jpe?g|svg)$/i,
use: "file-loader",
include: path.join(__dirname, "src")
}
]
}
};