Vite plugin for optimizing glTF 3D models during build. Version 4.0.0 is the latest stable release. Released by The New York Times R&D, it relies on the glTF Transform ecosystem for transforms like texture resizing, Draco compression, and mesh quantization. Unlike other glTF tooling that requires separate CLI steps, this integrates seamlessly into Vite's build pipeline. It is ESM-only, requires Node 18+, and all peer dependencies must be installed manually.
npm install vite-plugin-gltfVerified import paths — ran on the pinned version, not inferred.
Configures vite-plugin-gltf with texture resizing and Draco compression transforms.
Upgrade Node.js to version 18 or higher.
Run: npm install @gltf-transform/core @gltf-transform/extensions @gltf-transform/functions
Add to tsconfig.json: { "compilerOptions": { "skipLibCheck": true } }Replace encoder/decoder options with the draco() transform function.
Update Vite to version 5 or later.
Install it: npm install @gltf-transform/core
Change to import statement or use dynamic import(). Ensure project is ESM (type: module in package.json).
Use it inside Vite's plugins array: export default defineConfig({ plugins: [gltf({...})] })Update Vite to version 5+.