https://github.com/vanruesc/esbuild-plugin-glsl
A GLSL plugin for esbuild.
https://github.com/vanruesc/esbuild-plugin-glsl
Last synced: 9 days ago
JSON representation
A GLSL plugin for esbuild.
- Host: GitHub
- URL: https://github.com/vanruesc/esbuild-plugin-glsl
- Owner: vanruesc
- License: zlib
- Created: 2020-12-07T22:36:09.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-03-20T16:03:54.000Z (27 days ago)
- Last Synced: 2025-03-31T04:04:54.386Z (16 days ago)
- Language: TypeScript
- Homepage:
- Size: 396 KB
- Stars: 41
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-esbuild - esbuild-plugin-glsl
README
# esbuild-plugin-glsl
[](https://github.com/vanruesc/esbuild-plugin-glsl/actions)
[](https://www.npmjs.com/package/esbuild-plugin-glsl)An [esbuild plugin](https://esbuild.github.io/plugins/) that adds support for `.frag`, `.vert`, `.glsl` and `.wgsl` [file imports](https://esbuild.github.io/content-types/#text) with optional shader minification.
## Installation
```sh
npm install esbuild-plugin-glsl
```## Usage
```js
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. | follows [minify](https://esbuild.github.io/api/#minify) |
| resolveIncludes | When enabled, shaders can include other shaders with the custom `#include "path"` directive. | `true` |
| preserveLegalComments | Preserves comments that start with `//!` or `/*!` or include `@license` or `@preserve`. | follows [legal-comments](https://esbuild.github.io/api/#legal-comments) |### TypeScript
To make the TypeScript compiler know how to handle shader sources, add a `shaders.d.ts` [ambient declaration file](https://basarat.gitbook.io/typescript/type-system/intro/d.ts) to your project:
```ts
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.