Documentation
¶
Index ¶
- func BuildClient(cfg *config.Config) error
- func BuildSSRWorker(cfg *config.Config) error
- func BuildStyles(cfg *config.Config) error
- func PublicFileHandler(cfg *config.Config, next http.Handler) http.Handler
- func ResolveAssets(outDir string) (cssPath string, jsPath string)
- func StaticFileHandler(cfg *config.Config) http.Handler
- func WatchAndRebuild(cfg *config.Config, onChange func(changeType string)) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildClient ¶
BuildClient bundles Zyra's client runtime and every page component into code-split, tree-shaken JavaScript chunks, builds the Tailwind CSS bundle, and writes manifest.json mapping every entry point to its final (content-hashed) output path.
func BuildSSRWorker ¶
BuildSSRWorker bundles the SSR worker script into a single, Bun/Node-compatible ESM file at <cfg.OutDir>/ssr-worker.js, for production use in place of running the raw TypeScript source directly. React and react-dom are left external so the bundle resolves them from the project's own node_modules at runtime instead of duplicating them into the bundle.
func BuildStyles ¶
BuildStyles resolves Tailwind CSS utilities for the project (using cfg.Tailwind.Content to tell Tailwind's CLI what to scan) and bundles the result with esbuild into <cfg.OutDir>/static, updating manifest.json in place. It rebuilds only CSS, without touching any JavaScript, which makes it cheap to call on every class-name change detected by the dev watcher.
func PublicFileHandler ¶
PublicFileHandler serves files from cfg.PublicDir directly at the site root (e.g. public/favicon.ico -> /favicon.ico), applying the same cache policy as StaticFileHandler. Any request path that doesn't match a file in cfg.PublicDir falls through to next (typically Zyra's page/SSR handler).
func ResolveAssets ¶
ResolveAssets reads <outDir>/manifest.json and returns the public URL paths for the primary CSS bundle and the primary client JS bundle.
func StaticFileHandler ¶
StaticFileHandler serves built client assets (JS/CSS bundles) from <cfg.OutDir>/static, with no-cache headers in dev mode and a long-lived immutable cache in production (safe because output filenames are content-hashed).
func WatchAndRebuild ¶
WatchAndRebuild starts esbuild's native watch mode for both the client JS/page bundle and the Tailwind CSS bundle. Each rebuild invokes onChange (debounced by 300ms; simultaneous JS and CSS rebuilds within that window are coalesced into a single "all" call). WatchAndRebuild returns once both watchers are established; the underlying esbuild watch goroutines keep running for the lifetime of the process.
Types ¶
This section is empty.