-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
35 lines (31 loc) · 927 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
34
35
const express = require('express');
const webpack = require('webpack');
const webpackMiddleware = require('webpack-dev-middleware');
// Setup
const app = express();
// const port = process.env['WEB_APP_PORT'];
const port = 3001
const config = require('./webpack.config.dev.js');
const compiler = webpack(config);
const middleware = webpackMiddleware(compiler, {
publicPath: "/",
serverSideRender: true,
watchOptions: {
// Due to iOS devices memory constraints
// disabling file watching is recommended
// ignored: /.*/
}
});
app.use(middleware)
app.get('/', (req, res) => {
res.sendFile('public/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) { }