Skip to content

rottencandy/esbuild-plugin-spglsl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esbuild-plugin-spglsl

An esbuild plugin for spglsl.

Adds support for importing shaders from *.glsl, *.vert & *.frag files.

Usage

  1. Install the plugin:
npm install --save-dev esbuild-plugin-spglsl
  1. 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",
      },
    }),
   ],
 })
  1. Import and use shaders:
import myShader from './myShader.frag';

...
gl.shaderSource(sh, myShader);