A Babel transform plugin that integrates glslify, allowing developers to import and inline GLSL shaders directly in JavaScript code using template literals. Version 2.0.0 is the latest stable release, targeting Node >=0.12. It enables ES6 syntax with glslify, supports tagged template strings for shader code, and works alongside other Babel transforms. Unlike the original browserify transform, this plugin is compatible with Babel-based build pipelines, making it a key tool for WebGL projects using modern JavaScript tooling. The package has no recent updates and relies on external glslify installation.
npm install babel-plugin-glslifyVerified import paths — ran on the pinned version, not inferred.
Basic setup showing import of glslify, configuration of the Babel plugin, and usage of a tagged template literal to process GLSL shader code.
npm install --save glslify
Use import glsl from 'glslify' instead of require.
If using Babel 7, try using 'babel-plugin-glslify' with the 'legacy' decorator or upgrade to a newer plugin if available.
Consider using alternative bundler transforms like webpack-glslify-loader or rollup-plugin-glslify if encountering issues.
Use glslify directly or a loader for standalone shader files if needed.
Run: npm install --save glslify
Replace const glsl = require('glslify') with import glsl from 'glslify'Ensure babel-plugin-glslify is installed: npm install --save-dev babel-plugin-glslify, and add it to babel plugins as 'glslify' (not 'babel-plugin-glslify').
Use import glsl from 'glslify' and ensure your build tool supports ES module interop.