https://github.com/ustymukhman/bun-plugin-glsl
πΈοΈ Import, inline (and compress) GLSL shader files π
https://github.com/ustymukhman/bun-plugin-glsl
bun bun-plugin bunjs glsl glsl-shaders plugin shaders threejs webgl webgl-shaders webgpu webgpu-shaders
Last synced: 4 months ago
JSON representation
πΈοΈ Import, inline (and compress) GLSL shader files π
- Host: GitHub
- URL: https://github.com/ustymukhman/bun-plugin-glsl
- Owner: UstymUkhman
- License: mit
- Created: 2025-02-06T14:18:57.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2025-02-24T17:29:50.000Z (4 months ago)
- Last Synced: 2025-02-24T18:30:31.603Z (4 months ago)
- Topics: bun, bun-plugin, bunjs, glsl, glsl-shaders, plugin, shaders, threejs, webgl, webgl-shaders, webgpu, webgpu-shaders
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/bun-plugin-glsl
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bun Plugin GLSL
> Import, inline (and compress) GLSL shader files

_Inspired by [vite-plugin-glsl](https://github.com/UstymUkhman/vite-plugin-glsl), compatible with [Babylon.js](https://www.babylonjs.com/), [three.js](https://threejs.org/) and [lygia](https://lygia.xyz/)._
## Installation ##
```bash
bun add bun-plugin-glsl --dev
```## Usage ##
```js
import glsl from 'bun-plugin-glsl';Bun.plugin(glsl());
```### With TypeScript ###
Add extension declarations to your [`types`](https://www.typescriptlang.org/tsconfig#types) in `tsconfig.json`:
```json
{
"compilerOptions": {
"types": [
"bun-plugin-glsl/ext"
]
}
}
```or as a [package dependency directive](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html#-reference-types-) to your global types:
```ts
///
```## Default Options ##
```js
glsl({
include: /\.(glsl|wgsl|vert|frag|vs|fs)$/, // RegExp of file extensions to import
removeDuplicatedImports: false, // Automatically remove an already imported chunk
warnDuplicatedImports: true, // Warn if the same chunk was imported multiple times
defaultExtension: 'glsl', // Shader suffix when no extension is specified
compress: false, // Compress output shader code
watch: true, // Recompile shader on change
root: '/' // Directory for root imports
})
```