Files
kjol/go/bundler/public_tailwind.go

20 lines
929 B
Go

package bundler
// CompileTailwind compiles a Tailwind v4 entry stylesheet with kjol's native
// engine, discovering utility candidates from the given source globs (relative
// to baseDir). The scanner is language-agnostic — it extracts candidate class
// tokens from any text file — so this works for markup authored in Go (e.g. the
// go-wasm-web example's webui components) just as well as .tsx/.html.
//
// entryCSS is the stylesheet source (typically `@import "tailwindcss";` plus an
// `@theme { … }` block). Returns minified CSS. This is the app-bundler engine
// (twCompile/scanSources) exposed for consumers that don't go through Build.
func CompileTailwind(entryCSS, baseDir string, sourceGlobs []string) (string, error) {
candidates := scanSources(baseDir, sourceGlobs)
compiled, _, err := twCompile(entryCSS, baseDir, candidates)
if err != nil {
return "", err
}
return m.String("text/css", compiled)
}