-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.dev.config.js
More file actions
37 lines (32 loc) · 923 Bytes
/
webpack.dev.config.js
File metadata and controls
37 lines (32 loc) · 923 Bytes
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
import _ from 'lodash';
import webpack from 'webpack';
import os from 'os';
import baseConfig from './webpack.base.config';
const netInterfaces = os.networkInterfaces();
const addresses = _(netInterfaces)
.map(value => value)
.flatten()
.filter(netInterface => (netInterface.family === 'IPv4' && !netInterface.internal))
.map(netInterface => netInterface.address)
.value();
const devServerConfig = {
hostname: _.first(addresses),
port: 8080,
};
const { entry:baseEntry, plugins:basePlugins, ...otherBaseConfig } = baseConfig;
const config = {
...devServerConfig,
...otherBaseConfig,
devtool: 'eval',
entry: [
`webpack-dev-server/client?http://${devServerConfig.hostname}:${devServerConfig.port}`,
'webpack/hot/dev-server',
...baseEntry,
],
plugins: [
...basePlugins,
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
],
};
export default config;