-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (23 loc) · 726 Bytes
/
server.js
File metadata and controls
31 lines (23 loc) · 726 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
29
30
31
const express = require('express');
const webpack = require('webpack');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const app = express();
const config = require('./webpack.config.dev.js');
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {
publicPath: '/',
stats: {
colors: true,
},
hot: true,
}));
// hot load
app.use(webpackHotMiddleware(compiler));
// 模拟服务器,返回json格式的报文。
app.use("/mock",express.static('mock'));
// 静态服务器
app.use(express.static('static'));
app.listen(config.devServer.port, () => {
console.log('start app listening on port 3000!\n');
});