-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·44 lines (34 loc) · 1.13 KB
/
index.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";
import path from 'path';
import express from 'express';
import webpack from 'webpack';
import history from 'connect-history-api-fallback';
import webpackDevMiddleware from 'webpack-dev-middleware';
import webpackHotMiddleware from 'webpack-hot-middleware';
import config from '../webpack/webpack.dev.config.babel.js';
const port = process.env.PORT || 3000;
const ip = process.env.IP || 'localhost';
const app = express();
const compiler = webpack(config);
app.use(history());
app.use(webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath,
headers: {'Access-Control-Allow-Origin': '*'},
stats: {
colors: true,
hash: false,
timings: true,
chunks: false,
chunkModules: false,
modules: false
}
}));
app.use(webpackHotMiddleware(compiler));
app.use('/static', express.static('public'));
app.get('*', (req, res) => res.sendFile(path.join( __dirname, 'index.html')));
app.listen( port, ip, error => {
if (error) throw error;
/*eslint-disable no-console */
console.info(`Listening on port ${port}. Open up http://${ip}:${port}/ in your browser.`);
/*eslint-enable no-console */
});