@samveys/vite

Versi
1.0.35 Nov 2026
Pasang
pnpm add @samveys/vite

Dari packages/vite/README.md di repository framework.

Halaman ini belum diterjemahkan. Kamu sedang membaca versi bahasa Inggris.

Vite integration for @samveys/view: @vite(...) tags and hashed asset serving. No runtime dependencies.

Set up

ts
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' })]
OptionDefault
publicDir<rootDir>/public
buildDirbuild (URLs start with /build/)
devServerUrlnone
hotFile<publicDir>/hot
manifest<publicDir>/<buildDir>/.vite/manifest.json

Tags

html
<head>@vite('resources/app.ts')</head>
  • Development (app.env === 'local' and a devServerUrl, or a public/hot file 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 is SVS_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.

ts
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'])