@samveys/vite
From packages/vite/README.md in the framework repository.
Vite integration for @samveys/view: @vite(...) tags and hashed asset serving. No runtime dependencies.
Set up
import { http } from '@samveys/http'
import { template } from '@samveys/template'
import { view } from '@samveys/view'
import { vite } from '@samveys/vite'
export const plugins = [http(), view(), template(), vite({ devServerUrl: 'http://localhost:5173' })]| Option | Default |
|---|---|
publicDir | <rootDir>/public |
buildDir | build (URLs start with /build/) |
devServerUrl | none |
hotFile | <publicDir>/hot |
manifest | <publicDir>/<buildDir>/.vite/manifest.json |
Tags
<head>@vite('resources/app.ts')</head>- Development (
app.env === 'local'and adevServerUrl, or apublic/hotfile holding the URL):<script type="module" src="http://localhost:5173/@vite/client">plus the entry from the dev server. - Production: the Vite 5+ manifest is read. The page gets
<link rel="stylesheet">for the entry's CSS and its imports' CSS,<script type="module">for the hashed file and<link rel="modulepreload">for imported chunks. An entry the manifest does not list isSVS_E110.
Serving assets
GET /build/assets/* serves public/build/assets/* with Cache-Control: public, max-age=31536000, immutable
(file names carry a content hash). Paths that leave that folder answer 404.
For other static files, put a reverse proxy or CDN in front, or serve public/ yourself.
Asset version
@samveys/inertia uses a hash of the manifest as its asset version, so clients reload after a deploy.
It is empty in development.
import { createVite } from '@samveys/vite'
const assets = createVite({ local: false, devServerUrl: undefined, hotFile: 'public/hot', manifestFile: 'public/build/.vite/manifest.json', base: '/build/' })
export const tags = (): Promise<string> => assets.tags(['resources/app.ts'])