add bundle command

This commit is contained in:
maddalax 2024-09-12 20:42:18 -05:00
parent f50ded8589
commit bccfd218f6
5 changed files with 25 additions and 4 deletions

View file

@ -3,7 +3,7 @@
"version": "1.0.0",
"main": "mhtml.js",
"scripts": {
"watch": "tsup ./mhtml.ts --watch --config ./tsup.config.ts",
"watch": "tsup ./mhtml.ts --watch --config ./tsup.config.ts --sourcemap inline",
"build": "tsup ./mhtml.ts --minify --config ./tsup.config.ts",
"tailwind:watch": "npx tailwindcss -i ./input.css -o ./output.css --watch",
"pretty": "prettier --write ."

View file

@ -10,7 +10,6 @@ export default defineConfig({
clean: false,
target: "esnext",
treeshake: false,
sourcemap: true,
platform: "browser",
outExtension: () => {
return {

View file

@ -215,6 +215,17 @@ func Body(children ...Renderable) Renderable {
return Tag("body", children...)
}
func Link(href string, rel string) Renderable {
return &Node{
tag: "link",
attributes: map[string]string{
"href": href,
"rel": rel,
},
children: make([]Renderable, 0),
}
}
func Script(url string) Renderable {
return &Node{
tag: "script",

View file

@ -2,6 +2,17 @@
run-app:
just run-gen && air & just watch-js & just watch-gen
bundle:
rm -rf dist
rm -rf assets/dist
just run-gen
go build .
cd assets/js && npm run build
just build-css
mkdir -p dist/assets/dist
cp -r assets/dist/* dist/assets/dist
cp mhtml dist/
run-gen:
go run ./tooling/astgen

View file

@ -10,8 +10,8 @@ func RootPage(children ...h.Renderable) h.Renderable {
return h.Html(
h.HxExtension("path-deps, response-targets, mutation-error"),
h.Head(
h.Script("https://cdn.tailwindcss.com"),
h.Script("/js/dist/mhtml.js"),
h.Link("/public/main.css", "stylesheet"),
h.Script("/public/mhtml.js"),
),
h.Body(
partials.NavBar(),