-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (28 loc) · 902 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
const path = require('path');
const webpack = require('webpack');
const config = require('./webpack/dev');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const express = require('express');
const app = express();
const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {
noInfo: false,
stats: {
colors: true,
cached: false
},
publicPath: config.output.publicPath
}));
app.use(webpackHotMiddleware(compiler));
app.use(express.static(path.resolve('./demos')));
app.use('/src', express.static(path.resolve('./src')));
app.use('/node_modules', express.static(path.resolve('./node_modules')));
const port = 8080;
const host = '0.0.0.0';
app.listen(port, host, function (err) {
if (err) {
return console.error(err);
}
console.log(`Listening at http://localhost:${port}/`);
});