initial port of the UI kit
This commit is contained in:
45
go/cmd/twcss/main.go
Normal file
45
go/cmd/twcss/main.go
Normal file
@@ -0,0 +1,45 @@
|
||||
// Command twcss compiles a Tailwind v4 stylesheet with kjol's native engine,
|
||||
// scanning explicit content globs for utility candidates. Unlike the app bundler
|
||||
// (which is wired to the frontend tree) it takes the entry, output, and content
|
||||
// globs as flags/args, so it works for markup authored in any language — used by
|
||||
// the go-wasm-web example, whose UI is written in Go.
|
||||
//
|
||||
// Usage (globs are relative to -base; pass "**" for a recursive walk):
|
||||
//
|
||||
// twcss -entry css/app.css -out wwwroot/app.css -base . 'webui/**/*.go' 'app/**/*.go'
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"kjol/bundler"
|
||||
)
|
||||
|
||||
func main() {
|
||||
entry := flag.String("entry", "", "path to the Tailwind entry stylesheet")
|
||||
out := flag.String("out", "", "output CSS path")
|
||||
base := flag.String("base", ".", "base dir the content globs are relative to")
|
||||
flag.Parse()
|
||||
|
||||
if *entry == "" || *out == "" {
|
||||
fmt.Fprintln(os.Stderr, "twcss: -entry and -out are required")
|
||||
os.Exit(2)
|
||||
}
|
||||
src, err := os.ReadFile(*entry)
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "twcss:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
css, err := bundler.CompileTailwind(string(src), *base, flag.Args())
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, "twcss:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
if err := os.WriteFile(*out, []byte(css), 0o644); err != nil {
|
||||
fmt.Fprintln(os.Stderr, "twcss:", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Printf("twcss: wrote %s (%d bytes)\n", *out, len(css))
|
||||
}
|
||||
Reference in New Issue
Block a user