ESBuild plugin that allows importing WebGL shaders from .glsl files directly into JavaScript or TypeScript projects. Currently at version 0.0.3, this plugin compresses GLSL code to reduce bundle size and promotes separation of concerns by keeping shaders in dedicated files rather than inline strings. It integrates with esbuild and tsup workflows, provides TypeScript type definitions, and supports common build configurations. Unlike manual shader loading or inline strings, this plugin automates shader compilation during the build step.
npm install esbuild-webglNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates plugin setup with esbuild and importing .glsl files as strings.
Rename shader files to .glsl extension.
Switch to esbuild for builds, or use a different shader loading approach for other bundlers.
Use a separate unminified build for development, or disable compression if plugin options allow (not currently exposed).
Change to: import { webglPlugin } from 'esbuild-plugin-webgl'Run: npm install esbuild-plugin-webgl --save-dev
Switch to ESM import: import { webglPlugin } from 'esbuild-plugin-webgl'