forked from adazzle/react-data-grid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack-dev-server.js
100 lines (95 loc) · 2.98 KB
/
webpack-dev-server.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"use strict";
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");
const WebpackDevServer = require("webpack-dev-server");
const RELEASE = process.argv.slice(2).includes("--release");
const config = {
mode: RELEASE ? "production" : "development",
devtool: "eval-source-map",
entry: {
index: [
"webpack-dev-server/client?http://localhost:3020/",
"webpack/hot/dev-server",
"./examples",
"./packages/react-data-grid/style/react-data-grid.less",
"./packages/react-data-grid-addons/style/react-data-grid-addons.less",
"./packages/react-data-grid-addons/node_modules/react-select/dist/react-select.css"
]
},
resolve: {
symlinks: false
},
plugins: [new webpack.HotModuleReplacementPlugin()],
module: {
rules: [
{
test: /\.js$/,
use: ["source-map-loader"],
enforce: "pre"
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: ["babel-loader"]
},
{
test: /\.css$/,
use: ["style-loader", "css-loader"]
},
{
test: /\.less$/,
use: ["style-loader", "css-loader", "less-loader"]
}
],
strictExportPresence: true
},
optimization: {
minimizer: [
new TerserPlugin({
terserOptions: {
parse: {
// we want terser to parse ecma 8 code. However, we don't want it
// to apply any minfication steps that turns valid ecma 5 code
// into invalid ecma 5 code. This is why the 'compress' and 'output'
// sections only apply transformations that are ecma 5 safe
// https://github.com/facebook/create-react-app/pull/4234
ecma: 8
},
compress: {
ecma: 5,
warnings: false,
// Disabled because of an issue with Uglify breaking seemingly valid code:
// https://github.com/facebook/create-react-app/issues/2376
// Pending further investigation:
// https://github.com/mishoo/UglifyJS2/issues/2011
comparisons: false,
// Disabled because of an issue with Terser breaking valid code:
// https://github.com/facebook/create-react-app/issues/5250
// Pending futher investigation:
// https://github.com/terser-js/terser/issues/120
inline: 2,
// https://github.com/terser-js/terser/issues/308
keep_fnames: true
},
mangle: {
safari10: true
},
output: {
ecma: 5,
comments: false,
// Turned on because emoji and regex is not minified properly using default
// https://github.com/facebook/create-react-app/issues/2488
ascii_only: true
}
}
})
]
}
};
const compiler = webpack(config);
const server = new WebpackDevServer(compiler, {
hot: true,
open: true,
contentBase: "examples"
});
server.listen(3020, "localhost");