-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
28 lines (28 loc) · 860 Bytes
/
server.js
File metadata and controls
28 lines (28 loc) · 860 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
require('colors')
const webpackConfig = require('./webpack.config');
const webpack = require('webpack');
const express = require('express');
const app = express();
const compiler = webpack(webpackConfig);
const port = process.env.PORT || 7878;
const mockMiddleware = require('express-mock-middleware')({
glob: 'mock/**/*.js'
});
const devMiddleware = require('webpack-dev-middleware')(compiler, {
publicPath: webpackConfig.output.publicPath,
stats: {
colors: true,
chunks: false
}
})
const hotMiddleware = require('webpack-hot-middleware')(compiler)
app.use(mockMiddleware);
app.use(devMiddleware)
app.use(hotMiddleware)
app.use('/', express.static('./page/'))
app.listen(port, function (err) {
if (err) return console.log(err);
devMiddleware.waitUntilValid(function () {
console.info(`server is runing on localhost:${port}`);
})
})