View Helpers
viteStyleTag()
Signature
Section titled “Signature”viteStyleTag() — returns string
Available in: controller
Category: Asset Functions
Description
Section titled “Description”Returns a tag for a Vite CSS entrypoint. In development, Vite injects CSS via
the JS client so this returns an empty string. In production, resolves the fingerprinted path.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
entrypoint | string | yes | — | The source CSS entrypoint path (e.g. “src/main.css”). |
head | boolean | no | false | Set to true to place output in the <head> area instead of inline. |
Examples
Section titled “Examples”// 1. Emit a <link> tag for a standalone CSS entrypoint inline (default)
// In development, returns an empty string — Vite injects CSS via the HMR JS client.
// In production, outputs a fingerprinted <link rel="stylesheet"> tag.
writeOutput(viteStyleTag("src/main.css"));
// 2. Place the <link> tag in the <head> instead of inline
// Passes the generated markup to $htmlHead() so it is buffered into the page <head>.
// Returns an empty string; nothing is printed at the call site.
viteStyleTag(entrypoint="src/main.css", head=true);
// 3. Emit a <link> tag for a page-specific CSS entrypoint
// Useful when a particular view has its own standalone stylesheet entrypoint
// defined in your Vite config alongside the primary JS bundle.
writeOutput(viteStyleTag("src/checkout.css"));