ESBuild plugin to load WebGL shaders from .glsl files, enabling direct import of GLSL shader code into JavaScript or TypeScript projects. Current stable version is 0.0.3 (released Jan 2025). Actively maintained with TypeScript support and shader minification. Differentiators: lightweight, integrates with esbuild and tsup, and compresses shader source for smaller bundles. Designed for WebGL, WebGPU, and Three.js projects needing separate shader files.
npm install esbuild-glslNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows esbuild configuration with webglPlugin, then imports .glsl files and compiles them into a WebGL program.
Ensure shader files have .glsl extension; rename or configure esbuild to load other extensions.
Use external GLSL linter in your build pipeline to catch syntax errors.
Add a global declaration file (e.g., shims.d.ts) with: declare module '*.glsl' { const value: string; export default value; }Run 'npm install esbuild-plugin-webgl' and ensure package name is correct.
Use import { webglPlugin } from 'esbuild-plugin-webgl' instead of require().Add plugins: [webglPlugin()] to your esbuild.build() call.