-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.config.js
59 lines (58 loc) · 1.76 KB
/
webpack.config.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
const fs = require("fs");
const path = require("path");
const webpack = require("webpack");
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
module.exports = {
node: {
fs: "empty",
module: "empty"
},
entry: {
build: "./src/index.js"
},
mode: process.env.NODE_ENV !== "production" ? "development" : "production",
devtool: "source-map",
output: {
path: path.join(__dirname, "public", "build"),
// production use relative path
publicPath: process.env.NODE_ENV !== "production" ? "/build/" : "build/",
chunkFilename: "[name].bundle.js",
filename: "[name].bundle.js"
},
optimization: {
minimizer: [
// we specify a custom UglifyJsPlugin here to get source maps in production
new UglifyJsPlugin({
cache: true,
parallel: true,
uglifyOptions: {
// FIXME: https://github.com/webpack/webpack/issues/6760
compress: {
inline: 1
},
ecma: 5,
mangle: true
},
sourceMap: true,
exclude: [/node_modules/]
})
]
},
module: {
rules: [
{ test: /\.css$/, loader: "style-loader!css-loader" },
{
test: /\.js$/,
loader: "babel-loader",
exclude: /node_modules/
}
]
},
plugins: [
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
})
// new BundleAnalyzerPlugin()
]
};