Import, inline (and minify) GLSL/WGSL shader files
npm install bun-plugin-glsl> Import, inline (and minify) GLSL/WGSL shader files
!npm
!GitHub package.json version
!GitHub
_Inspired by vite-plugin-glsl, compatible with Babylon.js, three.js and lygia._
``sh`
bun add bun-plugin-glsl --dev
`js
import glsl from 'bun-plugin-glsl';
Bun.plugin(glsl());
`
Add extension declarations to your types in tsconfig.json:
`json`
{
"compilerOptions": {
"types": [
"bun-plugin-glsl/ext"
]
}
}
or as a package dependency directive to your global types:
`ts`
///
`js``
glsl({
include: /\.(glsl|wgsl|vert|frag|vs|fs)$/, // RegExp of file extensions to import
removeDuplicatedImports: false, // Automatically remove an already imported chunk
warnDuplicatedImports: true, // Warn if the same chunk was imported multiple times
defaultExtension: 'glsl', // Shader suffix to use when no extension is specified
importKeyword: '#include', // Keyword used to import shader chunks
minify: false, // Minify/optimize output shader code
watch: true, // Recompile shader on change
root: '/' // Directory for root imports
})
For a practical usage example, changelog and know issues, please consult Vite plugin on which this one is based.