@pobidowski/esbuild-plugin-glslify

1.0.3 • Public • Published

esbuild-plugin-glslify

NOTE: this plugin is based on rollup-plugin-glslify

An esbuild plugin to import GLSL strings with glslify (a node.js-style module system for GLSL).

import frag from './shaders/frag.glsl';
console.log(frag);

Installation

yarn:

yarn add @pobidowski/esbuild-plugin-glslify --dev

NPM:

npm install --save-dev @pobidowski/esbuild-plugin-glslify

Usage

import { build } from 'esbuild';
import { glslify } from 'esbuild-plugin-glslify';

build({
	entryPoints: ['input.js'],
	outfile: 'output.js',
	bundle: true,
	plugins: [glslify({
        extensions: [ 'vs', 'fs', '.glsl', '.frag.shader' ],
		compress: true,
	})],
}).catch(e => {
    console.error(e);
    process.exit(1);
});

Configuration

The plugin responds to the following configuration options:

glslify({
    extensions: string[],   // a list of the file extensions this plugin should process.
                            // DEFAULT: [ 'vs', 'fs', 'vert', 'frag', 'glsl' ]
    
    compress: boolean,      // should the finial output be compressed (minified)
                            // DEFAULT: false 
});

Any unrecognized options will be forwarded to the glslify compiler:

glslify({
    transform: ['glslify-import'],  // this will configure glslify to import the `glslify-import` module
});

Read the glslify API options for more information.

See also

Package Sidebar

Install

npm i @pobidowski/esbuild-plugin-glslify

Weekly Downloads

1

Version

1.0.3

License

MIT

Unpacked Size

4.17 kB

Total Files

3

Last publish

Collaborators

  • pobidowski