diff --git a/.devfiles/init-bun.ts b/.devfiles/init-bun.ts new file mode 100644 index 0000000..851977d --- /dev/null +++ b/.devfiles/init-bun.ts @@ -0,0 +1,3 @@ +import sassPlugin from "@alecodes/bun-plugin-sass"; + +Bun.plugin(sassPlugin); diff --git a/.justfile b/.justfile index 676fd92..5da0849 100644 --- a/.justfile +++ b/.justfile @@ -3,6 +3,10 @@ mod repo ".devfiles/justfile" set dotenv-load := true +set shell := ["zsh", "-uc"] + +build_mode := env("BUILD_MODE", "DEVELOPMENT") + [private] docker-compose +ARGS: docker compose --file .devfiles/docker/docker-compose.dev.yaml --env-file .env --project-name compendium {{ARGS}} @@ -17,24 +21,13 @@ migrate: (docker-compose "run dbmate migrate") rollback: (docker-compose "run dbmate rollback") build-frontend: - #!/usr/bin/env bun - import sassPlugin from "@alecodes/bun-plugin-sass"; - - const entrypoints = Array.from( - new Bun.Glob("frontend/**/*.html").scanSync(".") - ); - - const result = await Bun.build({ - entrypoints, - outdir: "dist", - publicPath: "/", - splitting: true, - plugins: [sassPlugin], - naming: { - entry: "[dir]/[name].[ext]", - chunk: "assets/[name]-[hash].[ext]", - asset: "assets/[name]-[hash].[ext]", - }, - }); - - console.log("Assets compiled!"); + bun build \ + {{ if uppercase(build_mode) == "DEVELOPMENT" { "--watch" } else { "" } }} \ + --outdir 'dist' \ + --public-path '/' \ + --entry-naming '[dir]/[name].[ext]' \ + --chunk-naming 'assets/[name]-[hash].[ext]' \ + --asset-naming 'assets/[name]-[hash].[ext]' \ + --splitting \ + --css-chunking \ + {{ './frontend/**/*.html' }} diff --git a/bunfig.toml b/bunfig.toml index f694d83..72ab31b 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -1,3 +1,5 @@ +preload = ["./.devfiles/init-bun.ts"] + [serve.static] plugins = ["bun-plugin-sass"] diff --git a/frontend/css/style.css b/frontend/css/style.css index 818d406..9fab7db 100644 --- a/frontend/css/style.css +++ b/frontend/css/style.css @@ -1,3 +1,3 @@ h1 { - color: red; + color: blue; }