forked from WikiEducationFoundation/WikiEduDashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
42 lines (39 loc) · 1.16 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
const path = require('path');
const webpack = require('webpack');
module.exports = (env) => {
const jsConfig = require('./js.webpack')(env);
const cssConfig = require('./css.webpack')(env);
const doHot = env.development && !env.watch_js;
const entries = {
...jsConfig.entry,
...cssConfig.entry,
main: [...jsConfig.entry.main, ...cssConfig.entry.main],
styleguide: [...jsConfig.entry.styleguide, ...cssConfig.entry.styleguide]
};
if (doHot) {
// wrap entries with hot hooks
Object.keys(entries).forEach((key) => {
entries[key] = [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/only-dev-server',
].concat(entries[key]);
});
}
return {
...jsConfig,
entry: entries,
resolve: {
extensions: ['.js', '.jsx', '.styl'],
symlinks: false
},
module: {
rules: [...jsConfig.module.rules, ...cssConfig.module.rules],
},
devServer: {
port: 8080,
contentBase: path.join(__dirname, 'public'),
writeToDisk: true,
},
plugins: [...cssConfig.plugins, ...jsConfig.plugins, ...(doHot ? [new webpack.HotModuleReplacementPlugin()] : [])],
};
};