rollup-plugin-shader
convert GLSL files to ES6 modules
Last updated 3 years ago by hujiulong .
MIT · Original npm · Tarball · package.json
$ cnpm install rollup-plugin-shader 
SYNC missed versions from official npm registry.

rollup-plugin-shader

Convert GLSL files to ES6 modules:

// shader-vertex.glsl
attribute vec3 position;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
void main(void) {
    gl_Position = uPMatrix * uMVMatrix * vec4(position, 1.0);
}
// import a glsl file
import vertex from './shader-vertex.glsl';
console.log( typeof vertex );   // string

Installation

npm install --save-dev rollup-plugin-shader

Usage

// rollup.config.js
import shader from 'rollup-plugin-shader';

export default {
    input: 'src/main.js',
    output: {
        file: 'dist/bundle.js',
        format: 'cjs'
    },
    plugins: [
        shader( {
            // All match files will be parsed by default,
            // but you can also specifically include/exclude files
            include: '**/*.glsl',   // default: [ '**/*.glsl', '**/*.vs', '**/*.fs' ]
            exclude: [ 'node_modules/foo/**', 'node_modules/bar/**' ],

            // specify whether to remove comments
            removeComments: true,   // default: true
        } )
    ]
};

License

MIT

Current Tags

  • 0.0.3                                ...           latest (3 years ago)

3 Versions

  • 0.0.3                                ...           3 years ago
  • 0.0.2                                ...           3 years ago
  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 4
Last Day 0
Last Week 2
Last Month 7
Dependencies (1)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |