-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathserver.js
executable file
·31 lines (25 loc) · 973 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
var path = require('path');
var express = require('express');
var port = (process.env.PORT || 3000);
var app = express();
var publicPath = path.join(__dirname, 'public');
var imagesPath = path.join(__dirname, 'images');
var indexPath = path.join(__dirname, 'index.html');
app.use('/public', express.static(publicPath));
app.use('/images', express.static(imagesPath));
app.get('/', function (request, response) {
response.sendFile(indexPath);
});
if (process.env.NODE_ENV !== 'production') {
var webpack = require('webpack');
var webpackDevMiddleware = require('webpack-dev-middleware');
var webpackHotMiddleware = require('webpack-hot-middleware');
var config = require('./webpack.dev.config.js');
var compiler = webpack(config);
app.use(webpackHotMiddleware(compiler));
app.use(webpackDevMiddleware(compiler, {
noInfo: true,
publicPath: config.output.publicPath
}));
}
app.listen(port, () => console.log('Server running at port:' + port));