glslify as a babel transform
npm install babel-plugin-glslifybabel-plugin-glslify
====================
A babel transform for glslify.
``javascript
import glsl from "glslify";
const myFragShader = glsl
#pragma glslify: noise = require(glsl-noise/simplex/2d)
void main () {
float brightness = noise(gl_FragCoord.xy);
gl_FragColor = vec4(vec3(brightness), 1.);
};`
``
npm i -S glslify babel-plugin-glslify
Then you need to configure babel to run the transform. For example, if you were using browserify with babelify to run babel you would add the following to your package.json to run glslify:
`javascript``
// ... in your package.json
"browserify": {
"transform": [[
"babelify", {
"presets": ["es2015"],
"plugins": ["glslify"]
}
]]
}