esbuild-plugin-glsl

A GLSL plugin for esbuild.

Usage no npm install needed!

<script type="module">
  import esbuildPluginGlsl from 'https://cdn.skypack.dev/esbuild-plugin-glsl';
</script>

README

esbuild-plugin-glsl

CI Version

An esbuild plugin that adds support for .frag, .vert and .glsl file imports with optional shader minification.

Installation

npm install esbuild-plugin-glsl

Usage

import { build } from "esbuild";
import { glsl } from "esbuild-plugin-glsl";

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

TypeScript

To make the TypeScript compiler know how to handle GLSL files, add a glsl.d.ts file to your project:

declare module "*.glsl" {
    const value: string;
    export default value;
}

declare module "*.frag" {
    const value: string;
    export default value;
}

declare module "*.vert" {
    const value: string;
    export default value;
}

Contributing

Use the issue tracker to propose and discuss changes. Maintain the existing coding style. Lint and test your code.