Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit de4955d

Browse files
author
george
committed
add simple express server for debugging prod instance code
1 parent 0f3d875 commit de4955d

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"sass": "src/scss/undernet.scss",
1212
"style": "dist/undernet.css",
1313
"scripts": {
14-
"postinstall": "npm run build:dist",
14+
"setup": "npm i && npm run build:dist",
1515
"watch": "webpack-dev-server --config webpack.dev.js --progress",
1616
"build": "npm run js:build && webpack --config webpack.prod.js",
1717
"test": "jest",
@@ -71,6 +71,8 @@
7171
"eslint-config-prettier": "^6.0.0",
7272
"eslint-plugin-jsx-a11y": "^6.2.2",
7373
"eslint-plugin-react": "^7.14.2",
74+
"express": "^4.17.1",
75+
"express-static-gzip": "^2.0.5",
7476
"file-loader": "^4.0.0",
7577
"html-loader": "^0.5.5",
7678
"html-webpack-plugin": "^3.2.0",

server.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// sanity check: `node server.js`
2+
3+
const express = require("express")
4+
const path = require("path")
5+
const app = express()
6+
const PORT = process.env.PORT || 3000
7+
8+
const expressStaticGzip = require("express-static-gzip")
9+
10+
// app.use(express.static(path.join(__dirname, "build")))
11+
app.use("/", expressStaticGzip("build"))
12+
13+
app.get("*", function(req, res) {
14+
res.sendFile(path.join(__dirname, "/build/index.html"))
15+
})
16+
17+
app.listen(PORT, error => {
18+
return error
19+
? console.log(error)
20+
: console.info(
21+
`--> 🌎 Listening on port ${PORT}. Visit http://localhost:${PORT}/ in your browser.`
22+
)
23+
})

0 commit comments

Comments
 (0)