vite-plugin-slang
v1.0.1
Published
Vite plugin to compile and import Slang shaders
Readme
vite-plugin-slang
Vite plugin to load and automatically compile Slang shaders into WGSL/GLSL so they can be imported in your code as raw strings. Uses the WASM build of Slang for compilation.
Features
- Compiles Slang shader code to WGSL or GLSL
- Detects imports in Slang code and resolves them
- HMR support (also for imported modules)
- Provides compilation errors to the client
Usage
// yourFile.ts
import mySlangShader from './shaders/mySlangShader.slang?wgsl' // imports the shader as a WGSL string
import myOtherShader from './shaders/myOtherShader.slang?glsl' // imports the shader as a GLSL stringInstall
npm install --save-dev vite-plugin-slangAdd the plugin to your vite.config.ts:
import { defineConfig } from 'vite'
import slang from 'vite-plugin-slang'
export default defineConfig({
//...
plugins: [slang()],
})