-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (29 loc) · 937 Bytes
/
server.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
var webpack = require('webpack');
var config = require('./webpack.config');
var path = require('path');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');
var express = require('express');
var routes = require("./routes");
var app = new express();
var PORT = process.env.PORT || 1234;
//config.entry.main.unshift("webpack-dev-server/client?http://localhost:3000/", "webpack/hot/dev-server");
var compiler = webpack(config);
app.use(webpackDevMiddleware(
compiler,
{
noInfo: true,
publicPath: config.output.publicPath,
hot: true,
headers: { 'Access-Control-Allow-Origin': '*' }
}
));
app.use(webpackHotMiddleware(compiler));
app.use(routes);
app.listen(PORT, function (error) {
if (error) {
console.log(error);
} else {
console.log('Listening on port %s. Open up http://localhost:%s/ in your browser.', PORT, PORT);
}
});