glslify-import-loader
A webpack loader for glslify
that adds an import
directive to your shaders.
Usage
Configuration
Alternatively, you may apply these loaders automatically to all .glsl, .frag and .vert files by adding some additional configuration:
const webpack = ;moduleexports =module:rules:test: /\.$/exclude: /node_modules/loader: 'glslify-import-loader'test: /\.$/exclude: /node_modules/loader: 'raw-loader'test: /\.$/exclude: /node_modules/loader: 'glslify-loader'
glsl code
Given a common shader(common.glsl):
varying vec3 color;
You can import ./common.glsl
:
void
Result
/***//* 10 *//***/ {moduleexports = "varying vec3 color;\n"/***/ }/* 11 *//***/ {moduleexports = "" + + "void main() {\n \ngl_FragColor = vec4(color, 1.0);\n}"/***/ }
See also
glslify-import will import all glsl to a single module, the result of above example will be:
/* 11 *//***/ {moduleexports = "varying vec3 color;\nvoid main() {\n \ngl_FragColor = vec4(color, 1.0);\n}"/***/ }