diff --git a/Makefile b/Makefile index 4793373..3c07b6d 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ MAKE_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) install: deno install -dev: install prepare-static-files +dev: clean-build-output install prepare-static-files open http://localhost:8000 && deno -A ./scripts/dev.js format: @@ -40,12 +40,12 @@ lighthouse-badges: update-lighthouse-badges: lighthouse-badges $(MAKE_DIR)/scripts/update-badges.sh -clean: +clean-build-output: + rm -rf ./dist + +clean: clean-build-output deno clean rm -rf ./node_modules - rm -rf ./out - rm -rf ./dist - rm -rf ./dev rm -rf ./*lock* serve: build @@ -54,8 +54,8 @@ serve: build prepare-static-files: $(MAKE_DIR)/scripts/prepare-static-files.sh -build: install prepare-static-files - $(MAKE_DIR)/scripts/build.sh +build: clean-build-output install prepare-static-files + deno -A ./scripts/build.js deploy: version build $(MAKE_DIR)/scripts/deploy.sh \ No newline at end of file diff --git a/scripts/build.js b/scripts/build.js index 331b996..2a904eb 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -2,7 +2,7 @@ import * as esbuild from "npm:esbuild"; const VERSION = Deno.env.get("NEW_VERSION") || `v0.0.0`; -const result = await esbuild.build({ +await esbuild.build({ entryPoints: ["./src/index.ts"], bundle: true, platform: "browser", diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index 6dfc2eb..0000000 --- a/scripts/build.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -version="${NEW_VERSION:-"v0.0.0"}" - -echo -e "🛠️ Building ${COLOR_GREEN}MiroPad${NO_COLOR} ${COLOR_RED}${version}${NO_COLOR} \n" - -## copy over static files from src -rsync -r ./src/assets/images ./dist -rsync ./src/assets/favicon.ico ./dist -rsync ./src/index.html ./dist -rsync ./src/manifest.json ./dist -rsync ./src/service-worker.js ./dist -./node_modules/.bin/workbox injectManifest ./workbox-config.js - -echo "$version" >./dist/version - -deno -A ./scripts/build.js - -echo -e "👷‍♂️ Build finished 🙌\n" diff --git a/scripts/dev.js b/scripts/dev.js index f348f85..eb7b62c 100644 --- a/scripts/dev.js +++ b/scripts/dev.js @@ -1,6 +1,7 @@ import * as esbuild from "esbuild"; import miropad from "../package.json" with { type: "json" }; +const VERSION = `v0.0.0`; const context = await esbuild.context({ entryPoints: ["src/index.ts"], bundle: true, @@ -17,7 +18,7 @@ const context = await esbuild.context({ define: { "process.env.NODE_ENV": '"development"', TITLE_NAME: JSON.stringify("✍️ MiroPad"), - VERSION: JSON.stringify(miropad.version), + VERSION: JSON.stringify(VERSION), global: "globalThis", }, }); diff --git a/scripts/prepare-static-files.sh b/scripts/prepare-static-files.sh index 26dae5a..1d51da7 100755 --- a/scripts/prepare-static-files.sh +++ b/scripts/prepare-static-files.sh @@ -7,3 +7,8 @@ rsync ./src/index.html ./dist rsync ./src/manifest.json ./dist rsync ./src/service-worker.js ./dist ./node_modules/.bin/workbox injectManifest ./workbox-config.js + +## versioning static file generation +version="${NEW_VERSION:-"v0.0.0"}" +echo -e "🛠️ Building ${COLOR_GREEN}MiroPad${NO_COLOR} ${COLOR_RED}${version}${NO_COLOR} \n" +echo "$version" >./dist/version