Adds support for importing shaders from *.glsl
, *.vert
& *.frag
files.
- Install the plugin:
npm install --save-dev esbuild-plugin-spglsl
- Add the plugin to your esbuild build script:
const esbuild = require('esbuild')
const SpglslPlugin = require('esbuild-plugin-spglsl')
esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
plugins: [
SpglslPlugin({
compileMode: 'Optimize',
minify: true,
mangle: true,
mangle_global_map: {
my_uniform_to_rename: "x",
my_fragment_input_to_rename: "y",
},
}),
],
})
- Import and use shaders:
import myShader from './myShader.frag';
...
gl.shaderSource(sh, myShader);