From cfaf7ecc1fe0e55e8ed193cbb54cf6a5f1027897 Mon Sep 17 00:00:00 2001 From: aleidk Date: Fri, 21 Feb 2025 12:58:11 -0300 Subject: [PATCH] revert: refactor: build fronend via cli to allow watch mode this revert e0e8700baafd, the build via cli doesn't support plugins --- .devfiles/init-bun.ts | 3 --- .justfile | 36 ++++++++++++++++++++-------------- bunfig.toml | 2 -- frontend/css/style.css | 2 +- frontend/templates/base_1.html | 21 -------------------- 5 files changed, 22 insertions(+), 42 deletions(-) delete mode 100644 .devfiles/init-bun.ts delete mode 100644 frontend/templates/base_1.html diff --git a/.devfiles/init-bun.ts b/.devfiles/init-bun.ts deleted file mode 100644 index 851977d..0000000 --- a/.devfiles/init-bun.ts +++ /dev/null @@ -1,3 +0,0 @@ -import sassPlugin from "@alecodes/bun-plugin-sass"; - -Bun.plugin(sassPlugin); diff --git a/.justfile b/.justfile index 86cdad8..7192e56 100644 --- a/.justfile +++ b/.justfile @@ -3,10 +3,6 @@ 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}} @@ -14,7 +10,6 @@ docker-compose +ARGS: start-dev-services: (docker-compose "up --remove-orphans") dev: - watchexec --restart --clear --watch src --watch templates cargo run watchexec --restart --clear --watch src --watch dist cargo run migrate: (docker-compose "run dbmate migrate") @@ -22,13 +17,24 @@ migrate: (docker-compose "run dbmate migrate") rollback: (docker-compose "run dbmate rollback") build-frontend: - 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' }} + #!/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!"); diff --git a/bunfig.toml b/bunfig.toml index 72ab31b..f694d83 100644 --- a/bunfig.toml +++ b/bunfig.toml @@ -1,5 +1,3 @@ -preload = ["./.devfiles/init-bun.ts"] - [serve.static] plugins = ["bun-plugin-sass"] diff --git a/frontend/css/style.css b/frontend/css/style.css index 9fab7db..818d406 100644 --- a/frontend/css/style.css +++ b/frontend/css/style.css @@ -1,3 +1,3 @@ h1 { - color: blue; + color: red; } diff --git a/frontend/templates/base_1.html b/frontend/templates/base_1.html deleted file mode 100644 index 68fc370..0000000 --- a/frontend/templates/base_1.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - {% block title %}Axum web service!{% endblock %} - - - - - {% include "partials/header.html" %} -
- - {% block content %}{% endblock %} -
- - -