/png-mask-loader

A grayscale variant of png-alpha-loader

Primary LanguageJavaScriptMIT LicenseMIT

npm deps

PNG Mask Loader

A loader for webpack that exports the grayscale values of a PNG.

Install

npm install --save-dev png-mask-loader

Options

grayOnly: Whether to return the image gray, width, and size or just an array of gray values.

Usage

Use the loader either via your webpack config, CLI or inline.

Via webpack config (recommended)

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.mask\.png$/,
        use: 'png-mask-loader',
        options: {
          grayOnly: false
        }
      }
    ]
  }
}

In your application

var mask = require('./image.mask.png');

CLI

webpack --module-bind 'mask.png=png-mask-loader'

In your application

var mask = require('./image.mask.png');

Inline

In your application

var mask = require('raw-loader!./image.mask.png')