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

> Helper functions for writing build plugins for bb-cli

Latest version **1.0.1** (published 2018-07-04) · SEE LICENSE IN LICENSE license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @bb-cli/lib-build-plugin-helpers
pnpm add @bb-cli/lib-build-plugin-helpers
yarn add @bb-cli/lib-build-plugin-helpers
bun add @bb-cli/lib-build-plugin-helpers
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2018-07-04 |
| First published | 2018-07-04 |
| Weekly downloads | 0 |
| License | SEE LICENSE IN LICENSE |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | bb-cli |

## Links

- npm: https://www.npmjs.com/package/@bb-cli/lib-build-plugin-helpers
- npm.io page: https://npm.io/package/@bb-cli/lib-build-plugin-helpers

## Recent versions

- 1.0.1 (latest) — 2018-07-04

## README

# lib-build-plugin-helpers
Helper functions for writing build plugins for bb-cli

## Usage
- Install library

```bash
npm install --global @bb-cli/lib-build-plugin-helpers 
```

## Create a build plugin that adds a loader

```js
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:

```js
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.

```js
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)
  )
);
```

---
_Source: https://npm.io/package/@bb-cli/lib-build-plugin-helpers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
