watcher

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTailwind

func RunTailwind(projectRoot string) error

RunTailwind compiles the project's Tailwind CSS once (single-shot, synchronous). It reads from resources/css/input.css and writes to public/css/output.css using the standalone Tailwind CLI binary at .forge/bin/tailwindcss (zero npm dependency).

Returns an error if the binary is not installed or compilation fails. Run 'forge tool sync' to download the Tailwind CLI binary.

func RunTailwindWatch

func RunTailwindWatch(projectRoot string) (*exec.Cmd, error)

RunTailwindWatch starts the Tailwind CLI in --watch mode for continuous compilation during development. The returned *exec.Cmd can be used by the caller to stop the process (cmd.Process.Kill() or cmd.Wait() after cancellation).

Used by 'forge dev' to recompile CSS whenever .templ files change.

func ScaffoldTailwindInput

func ScaffoldTailwindInput(projectRoot string) error

ScaffoldTailwindInput creates the initial Tailwind CSS input file for a new project. Uses the scaffold-once pattern: existing files are never overwritten to preserve developer customizations.

Creates:

  • resources/css/input.css — Tailwind v4 @import directive

Tailwind v4 auto-detects content sources from all non-gitignored files, so no tailwind.config.js is needed.

Types

type DevServer

type DevServer struct {
	ProjectRoot string
	Config      *config.Config
	// contains filtered or unexported fields
}

DevServer orchestrates the development workflow: watch + parse + generate.

func NewDevServer

func NewDevServer(projectRoot string, cfg *config.Config) *DevServer

NewDevServer creates a new development server.

func (*DevServer) Start

func (d *DevServer) Start(ctx context.Context) error

Start starts the development server and blocks until context is cancelled.

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher wraps fsnotify with debouncing and file filtering.

func New

func New(onChange func(), debounce time.Duration) (*Watcher, error)

New creates a new file watcher with the given onChange callback and debounce duration.

func (*Watcher) Add

func (w *Watcher) Add(path string) error

Add adds a path to the watch list.

func (*Watcher) Close

func (w *Watcher) Close() error

Close closes the watcher and stops the watch loop.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL