@vttforge/vite-plugin
v0.6.1
Published
Vite plugin for Foundry VTT v14+ packages: browser ESM output with no hashing, CSS bundled, manifest copied with the version synced.
Readme
@vttforge/vite-plugin
The build contract for a Foundry VTT v14+ system or module, as a Vite plugin.
bun add -D @vttforge/vite-plugin vite// vite.config.mjs
import vttforge from '@vttforge/vite-plugin';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [vttforge({ id: 'my-system', kind: 'system', entry: 'scripts/main.ts' })],
});What it does
- Emits browser ES modules into
dist/with no hashed filenames. Foundry loads files by the fixed paths in the manifest. - Keeps class names through minification, so a sheet registered by class name keeps its key between builds. Prefer
registerSystem({ sheets })with anid; this is the fallback. - Bundles CSS into one stylesheet and rewrites the manifest's
stylesandesmodulesto the emitted paths. - Copies the manifest under Foundry's filename (
system.json/module.json) withversionsynced frompackage.json. - Copies
template.json,lang/,templates/andpacks/unchanged, plus every directory the manifest'spacks[].pathnames. Override the list withstaticAssets. - Emits external source maps with the sources embedded.
Options
| Option | Default | Meaning |
|---|---|---|
| id | required | The package id. Must match the manifest and the folder Foundry serves it from |
| kind | 'system' | 'system' or 'module'. Sets the base path (/systems/<id>/ vs /modules/<id>/) and the manifest filename |
| entry | 'scripts/main.mjs' | Entry script, relative to the project root |
| manifest | system.json / module.json | Manifest path, relative to the project root |
| staticAssets | ['template.json', 'lang', 'templates', 'packs'], plus the directory of every packs[].path the manifest declares | Files and directories copied into dist/ before each build |
Peer: vite ^8. Node 26+.
vttforge dev and vttforge build from @vttforge/cli run this plugin for you.
