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
|
'use strict';
const path = require('path');
const webpack = require('webpack');
const proxyServer = require('./proxy-server');
let localDevConfig = {};
try {
localDevConfig = require('./devConfig');
} catch (e) {}
let devConfig = Object.assign({}, require('./devConfig.defaults'), localDevConfig);
let devPort = process.env.PORT || devConfig.port;
let webpackCommon = require('./webpack.common');
function getEntrySources(sources) {
for (let i in sources) {
if (sources.hasOwnProperty(i)) {
sources[i].push('react-hot-loader/patch');
sources[i].push('webpack-dev-server/client?http://localhost:' + devPort);
sources[i].push('webpack/hot/only-dev-server');
}
}
return sources;
}
let webpackDevConfig = Object.assign({}, webpackCommon, {
entry: getEntrySources(devConfig.bundles),
devtool: 'eval-source-map',
output: {
path: path.join(__dirname, 'dist'),
publicPath: `http://localhost:${devPort}/onboarding/`,
filename: '[name].js'
},
devServer: {
port: devPort,
historyApiFallback: true,
publicPath: `http://localhost:${devPort}/onboarding/`,
contentBase: path.join(__dirname, 'dist'),
inline: true,
hot: true,
stats: {
colors: true,
exclude: ['node_modules']
},
before: proxyServer
},
plugins: [
new webpack.DefinePlugin({
DEV: true,
DEBUG: true
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.LoaderOptionsPlugin({
options: {
eslint: {
configFile: './.eslintrc',
emitError: true,
emitWarning: true
},
context: '/'
}
})
]
});
module.exports = webpackDevConfig;
|