-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (41 loc) · 1.1 KB
/
index.js
File metadata and controls
47 lines (41 loc) · 1.1 KB
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
45
46
47
const express = require('express');
const config = require('./config');
const webpack = require('webpack');
const webpackConfig = require('./webpack.config');
const fakeHMR = require('./fake-hmr');
const compiler = webpack(webpackConfig);
const watching = compiler.watch({
// Example watchOptions
aggregateTimeout: 300,
poll: undefined
}, (err, stats) => { // Stats Object
console.log(stats.toString({
chunks: false, // Makes the build much quieter
colors: true // Shows colors in the console
}))
if (stats.hasErrors()) {
console.log('didn\' t build')
return;
}
console.log('built');
fakeHMR.built();
});
const app = express();
fakeHMR.config({ app });
app.use(express.static('public'));
// require('./webpackRunner');
app.get('*', (req, res) => {
res.send(`<!DOCTYPE html>
<html lang="en">
<head>
<title>hi</title>
</head>
<body>
<div id="app"/>
<script src="/bundle.js" type="text/javascript"></script>
</body>
</html>`)
});
app.listen(config.PORT, function () {
console.log(`App currently running; navigate to localhost:${config.PORT} in a web browser.`);
});