A Go-based CLI tool to process HTML templates with Tailwind CSS component extraction and production build output.
- Extracts Tailwind component classes from HTML comments.
- Generates optimized CSS using Tailwind CLI.
- Rewrites templates to use component classes and links to the generated CSS.
- Removes development-only scripts from production templates.
- Go 1.24+
- Tailwind CSS CLI
- Install dependencies:
go install github.com/accentdesign/twgen@latest- Run the tool:
twgen build --helpTailwind template builder
Usage:
build [command]
Available Commands:
build Build production templates and CSS
completion Generate the autocompletion script for the specified shell
help Help about any command
Flags:
--build-dir string Output build directory (default "./build")
--comment-prefix string Component comment prefix (default "tw:")
-h, --help help for build
--tailwind-cli string Path to Tailwind CLI (default "./tailwindcss")
--template-dir string Input template directory (default "./templates")