A Rollup plugin for optimizing glTF 3D models during the bundling process, version 4.0.0. It integrates with the @gltf-transform ecosystem (core, extensions, functions) to apply transforms such as texture resizing, mesh deduplication, and quantization. Unlike manual CLI tools, it runs as part of a Rollup build, enabling per-file transforms and caching. The plugin is maintained by The New York Times R&D team and is released as-is. Compatible with Rollup 3+ and requires peer dependencies @gltf-transform/core, @gltf-transform/extensions, and @gltf-transform/functions at version 3.x.
npm install rollup-plugin-gltfVerified import paths — ran on the pinned version, not inferred.
Rollup configuration that optimizes glTF files by resizing textures to 1024x1024 and deduplicating meshes during build.
Ensure package.json includes '@gltf-transform/core': '^3.0.0'
Use import syntax or dynamic import() in CJS projects. Convert project to ESM if possible.
Always provide transforms as an array, e.g., gltf({ transforms: [myTransform] })Replace compress: true with transforms: [/* appropriate functions */]
Switch to import syntax or use dynamic import: const gltf = (await import('rollup-plugin-gltf')).default;Use 'import gltf from 'rollup-plugin-gltf'' and ensure your project is configured for ESM.
Run: npm install --save-dev @gltf-transform/core @gltf-transform/extensions @gltf-transform/functions