Registry / devops / rollup-plugin-glslify

rollup-plugin-glslify

JSON →
library1.3.1jsnpmunverified

A Rollup plugin that allows importing GLSL shader files (e.g., .glsl, .vert, .frag) as JavaScript strings, processed through glslify — a Node.js-style module system for GLSL. It supports include/exclude patterns, optional compression via glslify's minifier, and is TypeScript-compatible (ships types). Current stable is 1.3.1, with maintenance releases as needed. Differentiators: integrates glslify's modular shader system into Rollup builds, supports compression, and is part of the glslify ecosystem. Compared to raw string loaders, it resolves glslify imports and applies transforms.

npm install rollup-plugin-glslify
INSTALL
IMPORT
SIG · ROLLUP-PLUGIN-GLSL
R
rollup-plugin-glslify
devopsjavascriptv1.3.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import glslify from 'rollup-plugin-glslify'
const glslify = require('rollup-plugin-glslify')
ESM export only; named exports are not provided.
glslify
import glslify from 'rollup-plugin-glslify'
import { glslify } from 'rollup-plugin-glslify'
The package exports a single default function, not a named export.
glslify with TypeScript
import glslify from 'rollup-plugin-glslify'
import * as glslify from 'rollup-plugin-glslify'
TypeScript users: use default import. The module is declared with 'export default' in its types.

Shows a Rollup config using the plugin with include/exclude and compression, plus importing a .frag file.

// rollup.config.js import glslify from 'rollup-plugin-glslify'; import { defineConfig } from 'rollup'; export default defineConfig({ input: 'src/index.js', output: { dir: 'dist', format: 'es' }, plugins: [glslify({ include: ['**/*.glsl', '**/*.vert', '**/*.frag'], exclude: 'node_modules/**', compress: true // default: minify })] }); // src/index.js import frag from './shaders/example.frag'; console.log(frag); // GLSL string
Debug
Known issues
breakingIn v1.x, the plugin switched from glslify's older stream API to a newer sync API. Existing configs using custom transforms may break.
fix
Update custom transforms to return a string directly instead of using through2.
affects: >=1.0.0
deprecatedThe compress option still defaults to true, but glslify's built-in minifier may be slow for large shaders. Consider disabling compress in development.
fix
Set compress: false in development config, and only enable for production builds.
affects: >=1.0.0
gotchaFile extensions .vs, .fs, .vert, .frag, .glsl are included by default, but .vs and .fs may conflict with other asset loaders.
fix
Explicitly set include to only the extensions you need, e.g., include: ['**/*.glsl'].
affects: >=1.0.0
gotchaThe plugin does not produce source maps for the GLSL strings. Debugging compiled shaders may be difficult.
fix
Manually add source map support via a separate Rollup plugin or use glslify's --sourcemap flag.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'glslify'
glslify is not installed or listed as a dependency.
fix
Run 'npm install glslify' alongside rollup-plugin-glslify.
TypeError: glslify is not a function
Wrong import style (named import) causing undefined.
fix
Use default import: import glslify from 'rollup-plugin-glslify'
Module parse failed: Unexpected token (1:0) in file shader.glsl
The plugin is not processing the .glsl file because it's not included.
fix
Add .glsl to the include option or verify the file extension matches the pattern.
Error: Could not resolve './common.glsl' from 'shader.vert'
glslify's relative imports are resolved relative to the file, not the project root.
fix
Check the import path in the GLSL file and ensure it exists.
Upgrade
Version history
1.3.1latest on npm
Audit
Dependencies
rolluprequiredpeer dependency; plugin is designed for Rollup ≥0.60
glslifyrequiredcore dependency; performs GLSL module resolution and transforms
Agent activity
8 hits · last 30 days
node
6
Resources
rollup-plugin-glslify — npm install rollup-plugin-glslify · libregistry