-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevServer.js
35 lines (29 loc) · 1.04 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
var webpack = require('webpack')
, WebpackDevServer = require('webpack-dev-server')
, webpackConfig = require('./webpack.config')
, url = require('url')
, proxy = require('proxy-middleware')
, express = require('express')
, conf = require('./dev.config');
webpackConfig.plugins.push(new webpack.DefinePlugin({
dev: 'true'
}));
var app = require('./server');
app.use(express.static(__dirname));
app.use('/scripts', proxy(url.parse('http://localhost:' + conf.webPack.port.toString() + webpackConfig.output.publicPath)));
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html');
});
app.get('/test', function (req, res) {
res.sendFile(__dirname + '/tests/index.html')
});
var webpackServer = new WebpackDevServer(webpack(webpackConfig), {
publicPath: webpackConfig.output.publicPath,
contentBase: __dirname,
hot: true,
noInfo: false,
quiet: conf.webPack.silent,
stats: {colors: true}
});
app.listen(conf.port);
webpackServer.listen(conf.webPack.port, 'localhost', function () {});