-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver.js
More file actions
24 lines (22 loc) · 687 Bytes
/
Copy pathserver.js
File metadata and controls
24 lines (22 loc) · 687 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
const path = require("path"),
express = require("express"),
webpack = require("webpack"),
webpackConfig = require("./webpack.config.js"),
app = express(),
port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`App is listening on port ${port}`);
});
let compiler = webpack(webpackConfig);
app.use(
require("webpack-dev-middleware")(compiler, {
noInfo: true,
publicPath: webpackConfig.output.publicPath,
stats: { colors: true }
})
);
app.use(require("webpack-hot-middleware")(compiler));
app.use(express.static(path.resolve(__dirname, "dist")));
app.get("*", (req, res) => {
res.sendFile(path.resolve(__dirname, "dist", "index.html"));
});