{"id":22678,"library":"vite-plugin-gltf","title":"vite-plugin-gltf","description":"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.","status":"active","version":"4.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/nytimes/rd-bundler-3d-plugins","tags":["javascript"],"install":[{"cmd":"npm install vite-plugin-gltf","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-gltf","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-gltf","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for core glTF operations; peer dependency.","package":"@gltf-transform/core","optional":false},{"reason":"Required for extension support; peer dependency.","package":"@gltf-transform/extensions","optional":false},{"reason":"Provides transform functions like textureResize; peer dependency.","package":"@gltf-transform/functions","optional":false}],"imports":[{"note":"ESM-only since v3; CommonJS require will fail.","wrong":"const gltf = require('vite-plugin-gltf')","symbol":"default","correct":"import gltf from 'vite-plugin-gltf'"},{"note":"TypeScript users: use 'import type' for type-only imports to avoid runtime errors.","wrong":"import { PluginOptions } from 'vite-plugin-gltf'","symbol":"gltf (type)","correct":"import type { PluginOptions } from 'vite-plugin-gltf'"},{"note":"Plugin must be used inside defineConfig or an array of plugins, not as the default export.","wrong":"import gltf from 'vite-plugin-gltf'\nexport default gltf()","symbol":"defineConfig","correct":"import { defineConfig } from 'vite'\nimport gltf from 'vite-plugin-gltf'"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite';\nimport gltf from 'vite-plugin-gltf';\nimport { textureResize, draco } from '@gltf-transform/functions';\n\nexport default defineConfig({\n  plugins: [\n    gltf({\n      transforms: [\n        textureResize({ size: [1024, 1024] }),\n        draco()\n      ]\n    })\n  ]\n});","lang":"javascript","description":"Configures vite-plugin-gltf with texture resizing and Draco compression transforms."},"warnings":[{"fix":"Upgrade Node.js to version 18 or higher.","message":"Requires Node.js 18 or later due to ESM-only builds and modern APIs.","severity":"breaking","affected_versions":">=4.0"},{"fix":"Run: npm install @gltf-transform/core @gltf-transform/extensions @gltf-transform/functions","message":"Peer dependencies must be installed manually; optional dependencies are not included.","severity":"breaking","affected_versions":">=4.0"},{"fix":"Add to tsconfig.json: { \"compilerOptions\": { \"skipLibCheck\": true } }","message":"When using TypeScript, ensure 'skipLibCheck' is true or resolve types for @gltf-transform/* packages.","severity":"gotcha","affected_versions":">=4.0"},{"fix":"Replace encoder/decoder options with the draco() transform function.","message":"Transform options using 'encoder' and 'decoder' for Draco are deprecated; use 'draco()' from @gltf-transform/functions.","severity":"deprecated","affected_versions":">=3.0"},{"fix":"Update Vite to version 5 or later.","message":"Vite 5+ required; older Vite versions may cause plugin incompatibility.","severity":"gotcha","affected_versions":">=4.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Install it: npm install @gltf-transform/core","cause":"Missing peer dependency @gltf-transform/core.","error":"Error: Cannot find module '@gltf-transform/core'"},{"fix":"Change to import statement or use dynamic import(). Ensure project is ESM (type: module in package.json).","cause":"Using CommonJS require() for an ESM-only plugin.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module not supported"},{"fix":"Use it inside Vite's plugins array: export default defineConfig({ plugins: [gltf({...})] })","cause":"Using the plugin incorrectly (e.g., gltf as a default export outside Vite config).","error":"TypeError: gltf is not a function"},{"fix":"Update Vite to version 5+.","cause":"Using outdated Vite version that doesn't support modern Vite 5 flags.","error":"error: unknown option '--format es'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}