Documentation
¶
Overview ¶
Package vite renders the tags that load a Vite frontend, following the Laravel "hot file" model.
In development the starter's Vite plugin writes public/hot with the dev server URL; Tags then points the browser at that server. Otherwise Tags reads public/build/.vite/manifest.json and emits modulepreload, stylesheet and script tags for each entry and its recursive imports, deduplicated across entries. Every tag gets the CSP nonce, and the manifest's "integrity" values become SRI attributes.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// FS is the public directory (os.DirFS("public") or an embed.FS) holding
// the "hot" file and the build directory.
FS fs.FS
// Dev honours the hot file and re-reads the manifest on every call. Off
// (production), a stray hot file is ignored and the manifest is cached.
Dev bool
// BuildDir is the build directory inside FS and the URL prefix of built
// files (default "build").
BuildDir string
}
Config configures a Vite.
type Vite ¶
type Vite struct {
// contains filtered or unexported fields
}
Vite renders Vite tags; it is safe for concurrent use.
func New ¶
New returns a Vite. The manifest is read on first use, so an app can boot before the first build while the dev server runs.
func (*Vite) Asset ¶
Asset returns the URL of a file Vite processed ("resources/img/logo.png"), and false when neither the dev server nor the manifest knows it.
func (*Vite) HotURL ¶
HotURL returns the dev server URL while it runs (Dev on and a valid hot file), and "" otherwise; inertia.SSRConfig.HotURL uses it.
func (*Vite) ReactRefresh ¶
ReactRefresh returns the @vitejs/plugin-react preamble while the dev server runs, and nothing otherwise. Place it before Tags.