Registry / web-framework / vite-plugin-gltf

vite-plugin-gltf

JSON →
library4.0.0jsnpmunverified

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-gltf
INSTALL
IMPORT
SIG · VITE-PLUGIN-GLTF
V
vite-plugin-gltf
web-frameworkjavascriptv4.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import gltf from 'vite-plugin-gltf'
const gltf = require('vite-plugin-gltf')
ESM-only since v3; CommonJS require will fail.
gltf (type)
import type { PluginOptions } from 'vite-plugin-gltf'
import { PluginOptions } from 'vite-plugin-gltf'
TypeScript users: use 'import type' for type-only imports to avoid runtime errors.
defineConfig
import { defineConfig } from 'vite' import gltf from 'vite-plugin-gltf'
import gltf from 'vite-plugin-gltf' export default gltf()
Plugin must be used inside defineConfig or an array of plugins, not as the default export.

Configures vite-plugin-gltf with texture resizing and Draco compression transforms.

// vite.config.js import { defineConfig } from 'vite'; import gltf from 'vite-plugin-gltf'; import { textureResize, draco } from '@gltf-transform/functions'; export default defineConfig({ plugins: [ gltf({ transforms: [ textureResize({ size: [1024, 1024] }), draco() ] }) ] });
Debug
Known issues
breakingRequires Node.js 18 or later due to ESM-only builds and modern APIs.
fix
Upgrade Node.js to version 18 or higher.
affects: >=4.0
breakingPeer dependencies must be installed manually; optional dependencies are not included.
fix
Run: npm install @gltf-transform/core @gltf-transform/extensions @gltf-transform/functions
affects: >=4.0
gotchaWhen using TypeScript, ensure 'skipLibCheck' is true or resolve types for @gltf-transform/* packages.
fix
Add to tsconfig.json: { "compilerOptions": { "skipLibCheck": true } }
affects: >=4.0
deprecatedTransform options using 'encoder' and 'decoder' for Draco are deprecated; use 'draco()' from @gltf-transform/functions.
fix
Replace encoder/decoder options with the draco() transform function.
affects: >=3.0
gotchaVite 5+ required; older Vite versions may cause plugin incompatibility.
fix
Update Vite to version 5 or later.
affects: >=4.0
Errors
Common errors & fixes
Error: Cannot find module '@gltf-transform/core'
Missing peer dependency @gltf-transform/core.
fix
Install it: npm install @gltf-transform/core
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Using CommonJS require() for an ESM-only plugin.
fix
Change to import statement or use dynamic import(). Ensure project is ESM (type: module in package.json).
TypeError: gltf is not a function
Using the plugin incorrectly (e.g., gltf as a default export outside Vite config).
fix
Use it inside Vite's plugins array: export default defineConfig({ plugins: [gltf({...})] })
error: unknown option '--format es'
Using outdated Vite version that doesn't support modern Vite 5 flags.
fix
Update Vite to version 5+.
Upgrade
Version history
4.0.0latest on npm
Audit
Dependencies
@gltf-transform/corerequiredRequired for core glTF operations; peer dependency.
@gltf-transform/extensionsrequiredRequired for extension support; peer dependency.
@gltf-transform/functionsrequiredProvides transform functions like textureResize; peer dependency.
Agent activity
5 hits · last 30 days
node
4
OpenAI (training)
1
Resources
vite-plugin-gltf — npm install vite-plugin-gltf · libregistry