-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (30 loc) · 895 Bytes
/
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
const express = require('express');
const webpack = require('webpack');
const webpackMiddleware = require('webpack-dev-middleware');
// Setup
const app = express();
const port = '9090';
const config = require('./webpack.config.js');
const compiler = webpack(config);
const middleware = webpackMiddleware(compiler, {
publicPath: config.output.publicPath,
serverSideRender: false,
watchOptions: {
// Due to iOS devices memory constraints
// disabling file watching is recommended
ignored: /.*/
}
});
app.use(middleware);
app.get('/', (req, res) => {
res.sendFile('index.html', { root: __dirname });
});
// Launch app
app.listen(port, () => {
console.log(
'Launching app... http://localhost:' + port + '\n'
);
});
// Register app and middleware. Required for better
// performance when running from play.js
try { pjs.register(app, middleware); } catch (error) { }