-
Notifications
You must be signed in to change notification settings - Fork 5
/
webpack.dev.server.js
42 lines (37 loc) · 1.09 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
require('console-stamp')(console, {
pattern: 'HH:MM:ss',
label: false
});
const pathJoin = require('path').join;
const nodemon = require('nodemon');
const chokidarWatch = require('chokidar').watch;
const webpack = require('webpack');
const webpackDevServer = require('webpack-dev-server');
const webpackDevConfig = require('../config/webpack.dev.config');
const configUtils = require('../config/webpack.config.utils');
const devServerConfig = {
contentBase: pathJoin(configUtils.projectRoot, 'dist'),
publicPath: webpackDevConfig.output.publicPath,
watchOptions: {
ignored: /node_modules/
},
historyApiFallback: {
disableDotRule: true
},
compress: false,
hot: true,
lazy: false,
inline: true,
host: 'localhost',
port: 8080,
stats: {
colors: true
}
};
const compiler = webpack(webpackDevConfig);
const server = new webpackDevServer(compiler, devServerConfig);
server.listen(devServerConfig.port);
const handleEntriesFolder = () => nodemon.emit('restart');
chokidarWatch(`${configUtils.projectRoot}/src/entries/*.js`)
.on('add', handleEntriesFolder)
.on('unlink', handleEntriesFolder);