How matyeusm/vite-plugin-fvtt works
vite-plugin-fvtt is a Vite plugin for developing and building Foundry VTT modules and systems. Its main workflow loads Foundry environment and manifest settings, adapts Vite’s library build, then emits manifest-shaped assets, composed language files, and compiled packs. During development, a Vite server watches templates and languages, serves local resources, and proxies Foundry traffic; injected client code applies template and translation updates. The graph follows the plugin lifecycle and README capabilities; unsampled bundle, manifest-loader, middleware, and proxy internals are represented only at their supported module boundaries.
Main entry points: src/index.ts Plugin entry · server/index.ts Server setup · context.ts Plugin context · bundle.ts Bundle generation
Components 22
Plugin lifecycle
- Plugin entry
src/index.ts - Environment loader
src/config/environment.ts - Manifest loader
src/config/foundryvtt-manifest.ts - Vite options
src/config/vite-options.ts
Build resources
- Bundle generation
src/bundle.ts - Language loader
src/language/loader.ts - Language transformer
src/language/transformer.ts - Language validator
src/language/validator.ts - Pack compiler
src/packs/compile-packs.ts
Development server
- Server setup
src/server/index.ts - HTTP middleware
src/server/http-middleware.ts - Socket proxy
src/server/socket-proxy.ts - Template tracker
src/server/trackers/handlebars-tracker.ts - Language tracker
src/server/trackers/language-tracker.ts - HMR client
src/server/hmr-client.ts
Shared context
- Plugin context
src/context.ts - Path utilities
src/utils/path-utilities.ts
Other components
- Module developer
- Vite
- Foundry VTT
- Project files
- Build output
Connections 35
- Module developer → Vite: configures
- Vite → Plugin entry: invokes hooks
- Plugin entry → Environment loader: loads settings
- Plugin entry → Manifest loader: loads manifest
- Plugin entry → Vite options: adapts config
- Plugin entry → Plugin context: stores state
- Manifest loader → Plugin context: sets manifest
- Environment loader → Plugin context: sets environment
- Vite options → Plugin context: reads manifest
- Vite → Plugin entry: resolves config
- Plugin entry → Bundle generation: generates bundle
- Bundle generation → Project files: reads assets
- Bundle generation → Build output: writes assets
- Plugin entry → Pack compiler: compiles packs
- Pack compiler → Project files: reads pack sources
- Pack compiler → Build output: writes compiled packs
- Plugin entry → Language validator: validates translations
- Language validator → Language loader: loads built languages
- Language validator → Language transformer: compares keys
- Language loader → Project files: reads language files
- Language loader → Language tracker: registers files
- Vite → Server setup: starts dev server
- Server setup → Template tracker: initializes watcher
- Server setup → Language tracker: initializes watcher
- Server setup → HTTP middleware: installs middleware
- Server setup → Socket proxy: installs proxy
- Template tracker → Vite: sends update event
- Language tracker → Vite: sends update event
- Plugin entry → HMR client: injects client
- HMR client → Foundry VTT: refreshes applications
- Socket proxy → Foundry VTT: proxies sockets
- HTTP middleware → Project files: serves local files
- HTTP middleware → Foundry VTT: proxies requests
- Path utilities → Plugin context: reads configuration
- Path utilities → Project files: resolves local paths