forked from tsaiDavid/simple-redux-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devServer.js
29 lines (23 loc) · 769 Bytes
/
devServer.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
const path = require('path');
const express = require('express');
const webpack = require('webpack');
const config = require('./webpack.config.dev');
const app = express();
const compiler = webpack(config);
const host = 'http://localhost';
const port = process.env.npm_config_port ? process.env.npm_config_port : 3000;
app.use(require('webpack-dev-middleware')(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
app.use(require('webpack-hot-middleware')(compiler));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'index.html'));
});
app.listen(port, 'localhost', (err) => {
if (err) {
console.log(err);
return;
}
console.info('==> Listening on port %s. Open up %s:%s/ in your browser.', port, host, port);
});