esbuild-plugin-glsl
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

esbuild-plugin-glsl

CI Version

An esbuild plugin that adds support for .frag, .vert, .glsl and .wgsl 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
	})]
});

Options

Option Description Default
minify Enables or disables basic shader minification. false
resolveIncludes When enabled, shaders can include other shaders with the custom #include "path" directive. true

TypeScript

To make the TypeScript compiler know how to handle shader sources, add a shaders.d.ts file to your project:

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

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.

Dependencies (0)

    Dev Dependencies (11)

    Package Sidebar

    Install

    npm i esbuild-plugin-glsl

    Weekly Downloads

    489

    Version

    1.2.2

    License

    Zlib

    Unpacked Size

    10 kB

    Total Files

    8

    Last publish

    Collaborators

    • vanruesc