Skip to content

Commit

Permalink
feat: remove duplication in dev build tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
teomrd committed Nov 14, 2024
1 parent 718335a commit 9637576
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 28 deletions.
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
19 changes: 0 additions & 19 deletions scripts/build.sh

This file was deleted.

3 changes: 2 additions & 1 deletion scripts/dev.js
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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",
},
});
Expand Down
5 changes: 5 additions & 0 deletions scripts/prepare-static-files.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9637576

Please sign in to comment.