0.0.1 • Published 7 years ago

interpolate-loader-options-webpack-plugin v0.0.1

Weekly downloads
55
License
MIT
Repository
github
Last release
7 years ago

interpolate-loader-options-webpack-plugin

Webpack plugin to interpolate strings within loader options.

Install

npm install --save-dev interpolate-loader-options-webpack-plugin

Usage

Once installed, can be used in your webpack configuration file

const InterpolateLoaderOptionsPlugin = require('interpolate-loader-options-webpack-plugin');

module.exports = {
  ...
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
        {
          loader: 'my-loader',
           options: {
             value: 123,
             interpolated: '[name]'
             nested: {
               arrays:[
                 {
                   value:'sdff'
                 },
                 {
                   value: '[path]'
                 }
               ]
             }
           }
         }
        ]
      }
    ]
  }
  plugins: [
    ...
    new InterpolateLoaderOptionsPlugin({
      // Optional Array<Object>
      loaders: [{
        // Required String
        name: 'my-loader',

        // Optional Array<String>
        include: ['nested.arrays.1.value']
      }]
    })
  ]
};

options

loaders Array<Object>

This property is optional. Defines an array of loader configurations on how to interpolate each loader. Each loader configuration must have a name that corresponds to a name of a loader. Each loader configuration can have an include array of property paths within the options that need to be interpolated.