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", "version": "1.0.0",
"main": "mhtml.js", "main": "mhtml.js",
"scripts": { "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", "build": "tsup ./mhtml.ts --minify --config ./tsup.config.ts",
"tailwind:watch": "npx tailwindcss -i ./input.css -o ./output.css --watch", "tailwind:watch": "npx tailwindcss -i ./input.css -o ./output.css --watch",
"pretty": "prettier --write ." "pretty": "prettier --write ."

View file

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

View file

@ -215,6 +215,17 @@ func Body(children ...Renderable) Renderable {
return Tag("body", children...) 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 { func Script(url string) Renderable {
return &Node{ return &Node{
tag: "script", tag: "script",

View file

@ -2,6 +2,17 @@
run-app: run-app:
just run-gen && air & just watch-js & just watch-gen 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: run-gen:
go run ./tooling/astgen go run ./tooling/astgen

View file

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