This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

@bb-cli/lib-build-plugin-helpers

1.0.1 • Public • Published

lib-build-plugin-helpers

Helper functions for writing build plugins for bb-cli

Usage

  • Install library
npm install --global @bb-cli/lib-build-plugin-helpers 

Create a build plugin that adds a loader

const { createPlugin, addLoader } = require('@bb-cli/lib-build-plugin-helpers');
module.exports = createPlugin(
  addLoader({ test: /\.css$/, loaders: [ 'css-loader' ])
);

Add loader modules

Note: the css-loader shown above is supported by default by the BB-CLI tools, but other loaders like the sass loader are not. To add all the loaders required by your plugin, provide the full paths to the loader directories:

const loaderBasedir = loader => path.dirname(require.resolve(`${loader}/package.json`));

const { createPlugin, addLoaderModules } = require('@bb-cli/lib-build-plugin-helpers');
module.exports = createPlugin(
  addLoaderModules(
    [
      'style-loader',
      'css-loader',
      'sass-loader',
    ].map(loaderBasedir)
  )
);

Chaining rules

You can pass as many rules as you like to createPlugin.

const { createPlugin, addLoader, addLoaderModules } = require('@bb-cli/lib-build-plugin-helpers');
const path = require('path');

const loaderBasedir = loader => path.dirname(require.resolve(`${loader}/package.json`));

module.exports = createPlugin(
  addLoader({
    test: /\.(scss|sass)$/,
    loaders: [
      'style-loader',
      'css-loader?sourceMap&minimize',
      'sass-loader?sourceMap',
    ],
  }),
  // Provide full path to the loader modules
  addLoaderModules(
    [
      'style-loader',
      'css-loader',
      'sass-loader',
    ].map(loaderBasedir)
  )
);

Readme

Keywords

none

Package Sidebar

Install

npm i @bb-cli/lib-build-plugin-helpers

Weekly Downloads

3

Version

1.0.1

License

SEE LICENSE IN LICENSE

Unpacked Size

3.06 kB

Total Files

5

Last publish

Collaborators

  • backbase-admin
  • bb-cli