esbuild-plugin-glsl-minify

raw JSON →
0.0.1 verified Fri May 01 auth: no javascript

An esbuild plugin that adds support for importing GLSL, frag, vert, and WGSL shader files with optional minification and variable mangling. Current stable version is 0.0.1, released twice. Differentiators: lightweight, integrates directly into esbuild's bundling pipeline, respects reserved words and attribute naming when mangling. It is a niche plugin for projects using esbuild that need to include shaders as strings and optionally minify them.

error Cannot find module 'esbuild-plugin-glsl-minify'
cause Package name may be confused with other similar packages; ensure correct spelling.
fix
Run 'npm install esbuild-plugin-glsl-minify' and check package.json.
error TypeError: glsl is not a function
cause Incorrect import: default import instead of named import.
fix
Use 'import { glsl } from "esbuild-plugin-glsl-minify"'.
gotcha Plugin only processes shader files; make sure your .glsl, .frag, .vert, .wgsl files are imported as text (default behavior).
fix Ensure your bundling configuration does not set 'loader' for these extensions to something else.
gotcha Mangling only works when minify is also enabled; standalone mangle does nothing.
fix Set both minify: true and mangle: true in the plugin options.
npm install esbuild-plugin-glsl-minify
yarn add esbuild-plugin-glsl-minify
pnpm add esbuild-plugin-glsl-minify

Shows how to use the plugin with esbuild, enabling minification and variable mangling for imported shader files.

import { build } from 'esbuild';
import { glsl } from 'esbuild-plugin-glsl-minify';

build({
  entryPoints: ['input.js'],
  outfile: 'output.js',
  bundle: true,
  plugins: [glsl({
    minify: true,
    mangle: true
  })]
}).catch(() => process.exit(1));