New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

glslify-import-loader

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

glslify-import-loader

glslify-import-loader

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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 = require('webpack');

module.exports = {
    module: {
        rules: [{
            test: /\.(glsl|frag|vert)$/,
            exclude: /node_modules/,
            loader: 'glslify-import-loader'
        }, {
            test: /\.(glsl|frag|vert)$/,
            exclude: /node_modules/,
            loader: 'raw-loader'
        }, {
            test: /\.(glsl|frag|vert)$/,
            exclude: /node_modules/,
            loader: 'glslify-loader'
        }]
    }
}

glsl code

Given a common shader(common.glsl):

varying vec3 color;

You can import ./common.glsl:

#pragma glslify: import('./common.glsl')

void main() {
  gl_FragColor = vec4(color, 1.0);
}

Result

/***/
/* 10 */
/***/ (function(module, exports) {
        module.exports = "varying vec3 color;\n"
/***/ }),
/* 11 */
/***/ (function(module, exports) {
        module.exports = "" + __webpack_require__(10) + "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 */
/***/ (function(module, exports) {
        module.exports = "varying vec3 color;\nvoid main() {\n  \ngl_FragColor = vec4(color, 1.0);\n}"
/***/ }),

Keywords

FAQs

Package last updated on 22 Feb 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc