Skip to content

Commit

Permalink
feat: build all css
Browse files Browse the repository at this point in the history
  • Loading branch information
katallaxie authored Oct 18, 2024
1 parent 710e7b7 commit 2ef9252
Show file tree
Hide file tree
Showing 8 changed files with 383 additions and 26 deletions.
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.DEFAULT_GOAL := release

GO ?= go
GO_RUN_TOOLS ?= $(GO) run -modfile ./tools/go.mod
GO ?= go
GO_RUN_TOOLS ?= $(GO) run -modfile ./tools/go.mod
GO_TEST ?= $(GO_RUN_TOOLS) gotest.tools/gotestsum --format pkgname
GO_RELEASER ?= $(GO_RUN_TOOLS) github.com/goreleaser/goreleaser
GO_BENCHSTAT ?= $(GO_RUN_TOOLS) golang.org/x/perf/cmd/benchstat
GO_RELEASER ?= $(GO_RUN_TOOLS) github.com/goreleaser/goreleaser
GO_BENCHSTAT ?= $(GO_RUN_TOOLS) golang.org/x/perf/cmd/benchstat
GO_MOD ?= $(shell ${GO} list -m)

.PHONY: release
Expand All @@ -17,8 +17,9 @@ generate: ## Generate code.

.PHONY: bundle
bundle: ## Bundle the project.
$(GO_RUN_TOOLS) github.com/evanw/esbuild/cmd/esbuild --bundle --sourcemap --platform=neutral --packages=external --outfile=dist/fiber-htmx.esm.js src/main.ts
$(GO_RUN_TOOLS) github.com/evanw/esbuild/cmd/esbuild --bundle --minify --sourcemap --outfile=dist/fiber-htmx.min.js src/main.ts
$(GO_RUN_TOOLS) github.com/evanw/esbuild/cmd/esbuild --format=esm --packages=external --outdir=dist src/*.ts
# $(GO_RUN_TOOLS) github.com/evanw/esbuild/cmd/esbuild --bundle --sourcemap --platform=neutral --packages=external --outfile=dist/fiber-htmx.esm.js src/main.ts
# $(GO_RUN_TOOLS) github.com/evanw/esbuild/cmd/esbuild --bundle --minify --sourcemap --outfile=dist/fiber-htmx.min.js src/main.ts

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand Down
14 changes: 6 additions & 8 deletions examples/toasts/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"log"
"net/http"
"os"

htmx "github.com/zeiss/fiber-htmx"
Expand All @@ -19,6 +20,7 @@ import (
"github.com/zeiss/pkg/server"

"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/filesystem"
"github.com/gofiber/fiber/v2/middleware/logger"
"github.com/gofiber/fiber/v2/middleware/recover"
"github.com/gofiber/fiber/v2/middleware/requestid"
Expand Down Expand Up @@ -73,21 +75,14 @@ func (c *exampleController) Get() error {
},
Head: []htmx.Node{
htmx.Link(
htmx.Attribute("href", "https://cdn.jsdelivr.net/npm/daisyui/dist/full.css"),
htmx.Attribute("href", "/assets/output.css"),
htmx.Attribute("rel", "stylesheet"),
htmx.Attribute("type", "text/css"),
),
htmx.Script(
htmx.Attribute("src", "https://unpkg.com/[email protected]"),
htmx.Attribute("type", "application/javascript"),
),
htmx.Script(
htmx.Attribute("src", "https://cdn.tailwindcss.com"),
),
htmx.Script(
htmx.Attribute("src", "https://unpkg.com/[email protected]"),
htmx.Defer(),
),
},
},
htmx.Body(
Expand Down Expand Up @@ -330,6 +325,9 @@ func (w *webSrv) Start(ctx context.Context, ready server.ReadyFunc, run server.R
app.Use(requestid.New())
app.Use(logger.New())
app.Use(recover.New())
app.Use("/assets", filesystem.New(filesystem.Config{
Root: http.Dir("./dist"),
}))

app.Get("/", htmx.NewHxControllerHandler(func() htmx.Controller {
return &exampleController{}
Expand Down
2 changes: 2 additions & 0 deletions gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
// +build generate

package htmx

//go:generate npx tailwindcss -i ./src/input.css -o ./out/out.css
Loading

0 comments on commit 2ef9252

Please sign in to comment.