Skip to content

befunkyinc/esbuild-plugin-glslify-minify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esbuild-plugin-glslify-minify

Compile GLSL shaders and minify. Based on the following projects:

Usage

npm install --save-dev @befunky/esbuild-plugin-glslify-minify

Configuration

esbuildPluginGlslifyMinify({
  // What extensions to compile. Defaults:
  extensions: ['vs', 'fs', 'vert', 'frag', 'glsl'],

  // Glslify options
  // See https://github.com/glslify/glslify#var-src--glslcompilesrc-opts
  glslify: {
    basedir: './helpers',
  },

  // Minification options 
  // See https://github.com/leosingleton/webpack-glsl-minify#loader-options
  minify: {
    preserveUniforms: true,
    preserveDefines: true,
    removeGlslifyDefinition: true, // Removes "#define GLSLIFY 1", false by default
  },

  // To avoid minification, omit the config or set it to a falsy value, e.g.
  minify: false,

});

Usage in Gulp task

import gulpEsbuild from 'gulp-esbuild';
import esbuildPluginGlslifyMinify from 'esbuild-plugin-glslify-minify';

gulp.task('js-app', () => {
  return gulp.src('./path/to/index.js')
    .pipe(gulpEsbuild({
      plugins: [
        esbuildPluginGlslifyMinify({
          // See configuration (above)
        }),
      ],
      // other esbuild options
    }))
});