From 082f254da017a9e87cc4c16fcf8658bd865f056d Mon Sep 17 00:00:00 2001 From: Alexander Polynomdivision Date: Wed, 3 Oct 2018 20:24:06 +0200 Subject: [PATCH] feat: Error pages + Makefile improvements Error pages: Add error pages for 404 and 50X errors by nginx Makefile improvements: Remove shit.sh and replace it by improving the Makefile --- frontend/Makefile | 33 +++++++++++++++++---------------- frontend/index.html | 1 - frontend/shit.sh | 1 + frontend/src/error.html | 13 +++++++++++++ frontend/src/lost.html | 13 +++++++++++++ server/nginx.conf | 14 ++++++++++++++ 6 files changed, 58 insertions(+), 17 deletions(-) delete mode 100644 frontend/index.html create mode 100644 frontend/src/error.html create mode 100644 frontend/src/lost.html diff --git a/frontend/Makefile b/frontend/Makefile index 13570cd..2fca8ad 100644 --- a/frontend/Makefile +++ b/frontend/Makefile @@ -1,12 +1,3 @@ -dist/minified: - mkdir -p dist/minified - -UGLIFYJS := ./node_modules/.bin/uglifyjs -# $1: The file to minify -define minify - $(shell ${UGLIFYJS} --mangle --compress -o "./dist/minified/$(notdir $1)" -- $1) -endef - node_modules: npm install @@ -14,15 +5,25 @@ node_modules: watch: node_modules npm start +clean: + rm -rf dist/ + .PHONY: build -build: node_modules dist/minified +build: prod +prod: node_modules clean @echo Building with parcel ./node_modules/.bin/parcel build --out-dir dist/app src/index.html + ./node_modules/.bin/parcel build --out-dir dist src/lost.html src/error.html + sed -e "s/\/src/\/app\/src/g" --in-place dist/app/index.html - @echo Minifying - $(foreach file, $(wildcard dist/*.js), $(call minify, $(file))) - $(shell ls -lah ./dist/minified) + tar -czf lateinicus-web.tar.gz dist/ -.PHONY: watch -watch: - npm start +dev: node_modules clean + @echo Building with parcel + ./node_modules/.bin/parcel build --out-dir dist/app src/index.html + ./node_modules/.bin/parcel build --out-dir dist src/lost.html src/error.html + sed -e "s/\/src/\/app\/src/g" --in-place dist/app/index.html + + chmod 604 -R dist/app/* + chmod 604 dist/error.html dist/lost.html + chmod 705 dist dist/app diff --git a/frontend/index.html b/frontend/index.html deleted file mode 100644 index 7624f58..0000000 --- a/frontend/index.html +++ /dev/null @@ -1 +0,0 @@ - Lateinicus
diff --git a/frontend/shit.sh b/frontend/shit.sh index 167a91c..f4bd548 100644 --- a/frontend/shit.sh +++ b/frontend/shit.sh @@ -2,6 +2,7 @@ rm -rf dist/ ./node_modules/.bin/parcel build --out-dir dist/app src/index.html +./node_modules/.bin/parcel build --out-dir dist src/lost.html src/error.html chmod 705 dist dist/app chmod 604 dist/app/* diff --git a/frontend/src/error.html b/frontend/src/error.html new file mode 100644 index 0000000..d84d03a --- /dev/null +++ b/frontend/src/error.html @@ -0,0 +1,13 @@ + + + + Lateinicus - 50X + + +

Du hast einen Serverfehler gefunden!


+ Das sollte nicht passieren... Das ist dann wohl meine Schuld...
+ +
+ Zu Lateinicus + + diff --git a/frontend/src/lost.html b/frontend/src/lost.html new file mode 100644 index 0000000..905ab7a --- /dev/null +++ b/frontend/src/lost.html @@ -0,0 +1,13 @@ + + + + Lateinicus - 404 + + +

Du hast ein 404 entdeckt


+ Du solltest hier aber nicht sein...
+ +
+ Zu Lateinicus + + diff --git a/server/nginx.conf b/server/nginx.conf index 26886e9..cb02ff9 100644 --- a/server/nginx.conf +++ b/server/nginx.conf @@ -34,6 +34,20 @@ http { gzip on; gzip_min_length 256K; + + error_page 404 /lost.html; + error_page 500 502 503 504 /error.html; + + # Status page for 404 + location = /error.html { + root /srv/www; + } + + # Status page for 50X + location = /lost.html { + root /srv/www; + } + # Reverse Proxy location /api/ { # Seems weird, but it is (Prevent /api/api/)