forked from bdefore/universal-redux
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack-dev-server_es6.js
36 lines (30 loc) · 1002 Bytes
/
webpack-dev-server_es6.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
#!/usr/bin/env node
const Express = require('express');
const webpack = require('webpack');
const userConfig = require('./user-config');
const config = require('./merge-configs')(userConfig);
const webpackConfig = config.webpack.config;
const compiler = webpack(webpackConfig);
const host = config.server.host || 'localhost';
const port = parseInt(config.server.port, 10) + 1 || 3001;
const serverOptions = {
contentBase: 'http://' + host + ':' + port,
quiet: true,
noInfo: true,
hot: true,
inline: true,
lazy: false,
publicPath: webpackConfig.output.publicPath,
headers: { 'Access-Control-Allow-Origin': '*' },
stats: { colors: true }
};
const app = new Express();
app.use(require('webpack-dev-middleware')(compiler, serverOptions));
app.use(require('webpack-hot-middleware')(compiler));
app.listen(port, function onAppListening(err) {
if (err) {
console.error(err);
} else {
console.info('==> 🚧 Webpack development server listening on port %s', port);
}
});