-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
22 lines (19 loc) · 746 Bytes
/
server.js
File metadata and controls
22 lines (19 loc) · 746 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// NOTE:
// - Use this server.js file if you wish to add some configurations or
// middlewares before running the project.
const express = require("express");
const path = require("path");
const app = express();
if (process.env.NODE_ENV !== "production") {
const webpack = require("webpack");
const WebpackDevMiddleware = require("webpack-dev-middleware");
const webpackConfig = require("./webpack.config.js");
app.use(WebpackDevMiddleware(webpack(webpackConfig)));
} else {
// This is for test running the build folder
app.use(express.static("build"));
app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "build/index.html"));
});
}
app.listen(process.env.port || 8080, () => console.log("Listening to 8080"));