babel-plugin-remove-glsl-comments
Remove comments in glsl shader source.
Example
in
// vertex.glsl.jsconst vs = `/* Projection uniforms */uniform mat4 viewMatrix;uniform mat4 projectionMatrix;uniform mat3 modelMatrix; /* Attributes */attribute vec3 positions;attribute vec3 instancePositions; main() { vec4 worldPosition = vec4(instancePositions + modelMatrix * positions, 1.); // resolved position of the current vertex gl_Position = projectionMatrix * viewMatrix * worldPosition;}`;
out
// vertex.glsl.jsconst vs = '\nuniform mat4 viewMatrix;\nuniform mat4 projectionMatrix;\nuniform mat3 modelMatrix;\n\nattribute vec3 positions;\nattribute vec3 instancePositions;\n\nmain() {\n vec4 worldPosition = vec4(instancePositions + modelMatrix * positions, 1.);\n gl_Position = projectionMatrix * viewMatrix * worldPosition;\n}\n';
Note: for safety, this plugin does not remove dynamically generated comments, e.g.
const vs = `/* MODULE STARTS */`;
const vs = `// END OF `;
Installation
$ npm install --save-dev babel-plugin-remove-glsl-comments
Usage
.babelrc
(Recommended)
Via .babelrc
With options:
Via CLI
$ babel --plugins remove-glsl-comments script.js
Via Node API
;
Options
patterns (Array)
An array of glob expressions that specify which files to apply this plugin to. Default ['*.js']
.