@samveys/vite
@vite tags, manifest reader and hashed asset serving
This list was read from version 1.0.2; run pnpm sync to refresh it.
import { createVite, serveAsset, vite, IMMUTABLE_CACHE_CONTROL } from '@samveys/vite'
Function (3)
createVite
Function
No documentation comment.
function createVite(options: ViteRuntimeOptions): Vite;
Exported from packages/vite/src/vite.ts
serveAsset
Function
Serves one file of `<publicDir>/<buildDir>/assets/` for a request path `file`. Paths that leave the folder (`..`, backslashes, NUL, absolute paths) are answered like a missing file.
function serveAsset(assetsDir: string, file: string): Promise<Response>;
Exported from packages/vite/src/assets.ts
vite
Function
The `@samveys/vite` plugin. Gives `@vite(...)` in templates its tags and serves `<publicDir>/<buildDir>/assets/*` with `Cache-Control: public, max-age=31536000, immutable`. In `local` with a dev server URL (or a `public/hot` file) the tags point at the dev server; otherwise they come from the Vite manifest, and an entry missing from it is `SVS_E110`.
function vite(options?: ViteOptions): import("@samveys/core").Plugin<ViteOptions>;
Exported from packages/vite/src/plugin.ts
Value (1)
IMMUTABLE_CACHE_CONTROL
Value
Built files carry a content hash in their name, so browsers may keep them forever.
const IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
Exported from packages/vite/src/assets.ts
Interface (4)
ManifestChunk
Interface
One entry of the Vite 5+ manifest (`.vite/manifest.json`).
interface ManifestChunk {
readonly file: string;
readonly src?: string;
readonly isEntry?: boolean;
readonly css?: readonly string[];
readonly assets?: readonly string[];
readonly imports?: readonly string[];
readonly dynamicImports?: readonly string[];
}
Exported from packages/vite/src/contracts.ts
Vite
Interface
No documentation comment.
interface Vite {
/** `<script>`/`<link>` tags for the given entries (`@vite(...)`). */
tags(entries: readonly string[]): Promise<string>;
/** Hash of the manifest (the Inertia asset version); `''` in development or before the first build. */
version(): Promise<string>;
}
Exported from packages/vite/src/vite.ts
ViteOptions
Interface
Types of `@samveys/vite`.
interface ViteOptions {
/** Directory served as the web root. Default `<rootDir>/public`. */
readonly publicDir?: string;
/** Build output folder inside `publicDir`, also the URL prefix (`/build/`). Default `build`. */
readonly buildDir?: string;
/** URL of the Vite dev server, e.g. `http://localhost:5173`. Used when `app.env` is `local`. */
readonly devServerUrl?: string;
/** File whose content is the dev server URL (written by a Vite plugin while it runs). Default `<publicDir>/hot`. */
readonly hotFile?: string;
/** Path of the Vite manifest. Default `<publicDir>/<buildDir>/.vite/manifest.json`. */
readonly manifest?: string;
}
Exported from packages/vite/src/contracts.ts
ViteRuntimeOptions
Interface
No documentation comment.
interface ViteRuntimeOptions {
/** `app.env === 'local'`: the dev server and the manifest file are re-checked on every render. */
readonly local: boolean;
readonly devServerUrl: string | undefined;
readonly hotFile: string;
readonly manifestFile: string;
/** URL prefix of built files, with both slashes: `/build/`. */
readonly base: string;
}
Exported from packages/vite/src/vite.ts
Type (1)
Manifest
Type
No documentation comment.
type Manifest = Readonly<Record<string, ManifestChunk>>;
Exported from packages/vite/src/contracts.ts