-
Notifications
You must be signed in to change notification settings - Fork 1
/
devServer.js
44 lines (33 loc) · 1.02 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"use strict";
var path = require('path');
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config.dev');
var express = require('express');
var proxy = require('express-http-proxy');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var proxyStatic = require('proxy-middleware');
var url = require('url');
var apiDomain = require('./config/devHost');
var app = express();
app.use(cookieParser());
app.use('/napi/*', proxy(apiDomain, {
forwardPath: function(req, res) {
return req.originalUrl;
}
}));
// server proxy
app.use('/static/', proxyStatic(url.parse('http://localhost:8080/static/')));
app.get('/**', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
var server = new WebpackDevServer(webpack(config), {
publicPath: config.output.publicPath,
hot: true,
historyApiFallback: true,
noInfo: false,
stats: { colors: true }
});
server.listen(8080, "localhost", function() {});
app.listen(8081);