Import, inline (and compress) GLSL shader files
Inspired by vite-plugin-glsl, compatible with Babylon.js, three.js and lygia.
bun add bun-plugin-glsl --dev
import glsl from 'bun-plugin-glsl';
Bun.plugin(glsl());
Add extension declarations to your types
in tsconfig.json
:
{
"compilerOptions": {
"types": [
"bun-plugin-glsl/ext"
]
}
}
or as a package dependency directive to your global types:
/// <reference types="bun-plugin-glsl/ext" />
glsl({
include: /\.(glsl|wgsl|vert|frag|vs|fs)$/, // RegExp of file extensions to import
warnDuplicatedImports: true, // Warn if the same chunk was imported multiple times
defaultExtension: 'glsl', // Shader suffix when no extension is specified
compress: false, // Compress output shader code
watch: true, // Recompile shader on change
root: '/' // Directory for root imports
})