-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathdev-server.config.js
91 lines (87 loc) · 2.41 KB
/
dev-server.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
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
// dev-server.config.js
// returns a webpack config object for running webpack-dev-server
// node modules
const path = require('path');
// webpack plugins
const webpack = require('webpack');
// return a webpack config
module.exports = (type = 'modern', settings) => {
// common config
const common = () => ({
devServer: {
allowedHosts: 'all',
client: {
overlay: true,
progress: false,
webSocketURL: {
hostname: settings.host(),
port: settings.port(),
},
},
devMiddleware: {
publicPath: '/',
},
headers: {
'Access-Control-Allow-Origin': '*'
},
host: settings.host(),
hot: true,
https: !!parseInt(settings.https()),
port: settings.port(),
static: {
directory: path.resolve(__dirname, settings.contentBase()),
publicPath: '/',
watch: {
usePolling: settings.poll() | 0,
ignored: /node_modules/,
},
},
},
devtool: false,
mode: 'development',
optimization: {
runtimeChunk: {
name: 'runtime'
}
},
output: {
filename: path.join('./js', '[name].js'),
path: path.resolve(__dirname, settings.paths.dist),
publicPath: settings.public() + '/',
},
plugins: [
new webpack.EvalSourceMapDevToolPlugin({
test: /\.(m?js|ts)($|\?)/i,
exclude: /\.(pcss|css)($|\?)/i,
}),
],
watchOptions: {
poll: settings.poll() | 0,
},
});
// configs
const configs = {
// development config
development: {
// legacy development config
legacy: {
},
// modern development config
modern: {
...common(),
},
},
// production config
production: {
// legacy production config
legacy: {
...common(),
},
// modern production config
modern: {
...common(),
},
}
};
return configs[process.env.NODE_ENV][type];
}