50 lines
1.6 KiB
Go
50 lines
1.6 KiB
Go
// Command twcss compiles a kjol app's Tailwind 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 kjol-website site, whose Go/WASM half writes its UI in Go.
|
|
//
|
|
// It compiles via tw.CompileAppFiles, so the -entry stylesheet is layered onto
|
|
// kjol's shared extension layer: base Tailwind → kjol extensions → this stylesheet.
|
|
// The entry therefore carries only brand and names none of the shared tokens.
|
|
//
|
|
// 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/tw"
|
|
)
|
|
|
|
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 := tw.CompileAppFiles(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))
|
|
}
|