generated from alecodes/base-template
refactor: build fronend via cli to allow watch mode
This commit is contained in:
parent
3e0dd79217
commit
e0e8700baa
4 changed files with 20 additions and 22 deletions
3
.devfiles/init-bun.ts
Normal file
3
.devfiles/init-bun.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import sassPlugin from "@alecodes/bun-plugin-sass";
|
||||
|
||||
Bun.plugin(sassPlugin);
|
||||
35
.justfile
35
.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' }}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
preload = ["./.devfiles/init-bun.ts"]
|
||||
|
||||
[serve.static]
|
||||
plugins = ["bun-plugin-sass"]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
h1 {
|
||||
color: red;
|
||||
color: blue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue