forked from trazyn/weweChat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.js
35 lines (29 loc) · 910 Bytes
/
dev.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
/**
* Setup and run the development server for Hot-Module-Replacement
* https://webpack.github.io/docs/hot-module-replacement-with-webpack.html
* @flow
*/
import express from 'express';
import webpack from 'webpack';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import config from '../config';
import webpackConfig from '../config/webpack.config.dev';
const app = new express();
const compiler = webpack(webpackConfig);
app.use(
webpackDevMiddleware(compiler, {
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true
},
})
);
app.use(webpackHotMiddleware(compiler));
app.listen(config.server.port, config.server.host, err => {
if (err) {
console.error(err);
return;
}
console.log(`Server is running with port ${config.server.port} 👏`);
});