From c5b48eb41c8611a992f4624f9b49b95fb726ecbc Mon Sep 17 00:00:00 2001 From: Lia Lenckowski Date: Tue, 25 Jul 2023 21:45:33 +0200 Subject: proper builds, that make deployment somewhat easy --- makefile | 30 +++++++++++++++++++++++++----- src/Main.hs | 4 ++-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/makefile b/makefile index b59e928..9ab4c64 100644 --- a/makefile +++ b/makefile @@ -1,8 +1,28 @@ -ESFLAGS = --target=esnext --sourcemap --format=esm +ESFLAGS = --target=esnext --format=esm + +deploy-dir: deploy deploy/bundle.js deploy/index.html deploy/bangs-ddgless +deploy.zip: deploy-dir + zip deploy.zip -r deploy + +deploy: + mkdir -p deploy -all: frontend/bundle.js watch: - esbuild frontend/main.ts --bundle --outfile=frontend/bundle.js $(ESFLAGS) --watch + esbuild frontend/main.ts --bundle --outfile=deploy/bundle.js $(ESFLAGS) --watch + +deploy/bundle.js: $(shell find frontend -name '*.ts') + esbuild frontend/main.ts --bundle --outfile=deploy/bundle.js $(ESFLAGS) + +deploy/index.html: frontend/index.html + cp $< $@ + +deploy/bangs-ddgless: $(shell find src -name '*.hs') + stack install --local-bin-path deploy + +clean: + stack clean --full + rm deploy/{bundle.js,index.html,bangs-ddgless} + rm deploy.zip + rmdir deploy # this may fail if the server was run, due to the bangs.json being generated -frontend/bundle.js: $(shell find frontend -name '*.ts') - esbuild frontend/main.ts --bundle --outfile=frontend/bundle.js $(ESFLAGS) +.PHONY: watch clean diff --git a/src/Main.hs b/src/Main.hs index 2599df5..ede3d14 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -30,10 +30,10 @@ instance Yesod Search where makeSessionBackend _ = return Nothing getHomeR :: Handler () -getHomeR = sendFile typeHtml "frontend/index.html" +getHomeR = sendFile typeHtml "index.html" getBundleR :: Handler () -getBundleR = sendFile typeJavascript "frontend/bundle.js" +getBundleR = sendFile typeJavascript "bundle.js" getBangsR :: Handler TypedContent getBangsR = do -- cgit v1.2.3-70-g09d2