-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathwebpack.dist.config.js
51 lines (45 loc) · 1.01 KB
/
webpack.dist.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
const path = require("path");
const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const webpack = require("webpack");
const webpackConfig = require("./webpack.base.config");
const MODE = "production";
const babelLoader = {
loader: "babel-loader",
options: {
presets: [
[
"env",
{
targets: {
node: "current",
browsers: ["last 2 versions", "ie >= 10"]
}
}
],
"react"
]
}
};
webpackConfig.module.rules
.filter(
({ test }) =>
["/\\.tsx?/", "/\\.jsx?$/", "/\\.[jt]sx?$/"].indexOf(test.toString()) > -1
)
.forEach(rule => rule.use.push(babelLoader));
webpackConfig.devtool = "source-map";
webpackConfig.optimization = {
minimizer: [
new UglifyJsPlugin({
sourceMap: true
})
]
};
webpackConfig.mode = MODE;
[
new webpack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(MODE)
})
].forEach(function(plugin) {
webpackConfig.plugins.push(plugin);
});
module.exports = webpackConfig;