Also works on local package
mattdesl opened this issue ยท 1 comments
mattdesl commented
This is awesome. ๐
I just realized you can use this for your local code as well. I'm currently using this to support regular glslify
syntax (instead of webpack require overload approach) by doing this in the webpack config:
...
module: {
loaders: [
// support modules like three-vignette-background, soundcloud-badge, etc
{
test: /node_modules/,
loader: 'ify'
}
],
postLoaders: [
// support local package.json browserify config
{
test: /\.js$/,
loader: 'ify'
}
]
}
And in my package.json:
...
"browserify": {
"transform": [
"glslify"
]
},
"glslify": {
"transform": [
"glslify-hex"
]
}
And in my src/index.js
I can do this:
const glslify = require('glslify')
const vertexShader = glslify(`
attribute vec4 position;
attribute vec2 uv;
uniform mat4 projectionMatrix;
uniform mat4 modelViewMatrix;
varying vec2 vUv;
void main () {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * position;
}
`.trim(), { inline: true })
hughsk commented
Thanks man! Glad it's proving useful ๐ I'll add a note to the readme about this :)