-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
34 lines (30 loc) · 835 Bytes
/
Copy pathapp.js
File metadata and controls
34 lines (30 loc) · 835 Bytes
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
const express = require("express");
const middleware = require("webpack-dev-middleware");
const webpackHotMiddleware = require("webpack-hot-middleware");
const webpack = require("webpack");
const webpackConfig = require("./webpack.config.js");
const path = require("path");
const app = express();
const compiler = webpack(webpackConfig);
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 8000;
app.use(
middleware(compiler, {
index: "./src/index.html",
publicPath: "/",
stats: {
colors: true,
},
})
);
app.use(
webpackHotMiddleware(compiler, {
log: console.log,
path: "/__webpack_hmr",
heartbeat: 10 * 1000,
})
);
app.use(express.static(path.join(__dirname, "src")));
app.listen(PORT, "0.0.0.0", function () {
console.log(`Running on PORT ${PORT}`);
});
module.exports = app;