Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

vite-plugin-lygia-resolver

Nek20MIT1.4.2TypeScript support: included

Convenient way to import GLSL shaders from Lygia library at build time

lygia, vite, glsl, webgl, webgpu, vitejs, plugin, threejs, shaders, vite-plugin, glsl-shaders, webgl-shaders, webgpu-shaders

readme

Vite Plugin Lygia

Import GLSL/WGSL shaders from Lygia - a granular and modular shader library.

npm GitHub package.json version GitHub

Key Benefits

  • Automatic resolution of Lygia's module paths directly in shaders at build time
  • Supports both GLSL and WGSL shader languages
  • Works with local files and Lygia's CDN-hosted modules
  • Enables modular shader composition with #include directives
  • Built-in caching for improved development performance

Installation

npm i vite-plugin-lygia-resolver --save-dev
# or
yarn add vite-plugin-lygia-resolver --dev
# or
pnpm add -D vite-plugin-lygia-resolver
# or
bun add vite-plugin-lygia-resolver --dev

Usage

// vite.config.js
import lygia from 'vite-plugin-lygia-resolver';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [lygia()]
});

With TypeScript

Add extension declarations to your types in tsconfig.json:

{
  "compilerOptions": {
    "types": [
      "vite-plugin-lygia-resolver/ext"
    ]
  }
}

or as a package dependency directive to your global types:

/// <reference types="vite-plugin-lygia-resolver/ext" />

Default Options

glsl({
  include: [                   // Glob pattern, or array of glob patterns to import
    '**/*.glsl', '**/*.wgsl',
    '**/*.vert', '**/*.frag',
    '**/*.vs', '**/*.fs'
  ],
  exclude: undefined,          // Glob pattern, or array of glob patterns to ignore
})