Skip to content
This repository was archived by the owner on Jun 11, 2023. It is now read-only.

Files

Latest commit

8d22dea · Nov 18, 2020

History

History
114 lines (98 loc) · 1.76 KB

use.md

File metadata and controls

114 lines (98 loc) · 1.76 KB

Use Plugin

Use plugins based on anymatch patterns.

Usage

Setup

Import UsePlugin

const {
  start,
  builtInPlugins: {
    UsePlugin
  }
} = require('reboost');

Add it to the plugins array

const {
  start,
  builtInPlugins: {
    UsePlugin
  }
} = require('reboost');

start({
  plugins: [
    UsePlugin({
      include: /regex/,
      use: [
        // Plugins
      ]
    })
  ]
})

Options

include

Type: Matcher

anymatch pattern to test file paths. If the test passes all plugin(s) in use will be used for the file.

exclude

Type: Matcher

anymatch pattern to test file paths. If the test passes the file will be excluded.

use

Type: ReboostPlugin | ReboostPlugin[]

Plugin(s) to use if the test passes for a file.

Example

Simple

With the following configuration, FilePlugin will be used for all files ending with .png.

const {
  start,
  builtInPlugins: {
    FilePlugin,
    UsePlugin
  }
} = require('reboost');

start({
  plugins: [
    UsePlugin({
      include: /\.png$/
      use: FilePlugin()
    })
  ]
})

Multiple plugins

You can use multiple plugins -

UsePlugin({
  include: '**/some-glob/*',
  use: [
    Plugin1(),
    Plugin2(),
    // and more
  ]
})

Multiple rules

Also, you can pass multiple rules/options, like so

UsePlugin(
  {
    include: '**/some-glob/*',
    use: Plugin1()
  },
  {
    include: '**/another-glob/*',
    use: Plugin2()
  }
)

Relative globs

You can use relative globs, they would be resolved against rootDir.

UsePlugin({
  include: './src/**/*.js',
  use: Plugin()
})