@bundles/bundles-filters
A bundler plugin for Bundles which allows you to create a series of dynamic filters to run through other bundlers.
Last updated a year ago by thezimmee .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @bundles/bundles-filters 
SYNC missed versions from official npm registry.

Bundles Filters Bundler

NPM version NPM downloads per month Travis branch Codacy code grade Codacy coverage Coverage Status JavaScript Style Guide code style: prettier semantic release Commitizen friendly License Greenkeeper badge

This is a bundler plugin for use with Bundles which filters files for use with other bundlers.

Environment support

Node CLI ES Module Browser UMD
x x

Install

Make sure Bundles is installed.

npm install @bundles/bundles-filters -D

Usage

See configuring Bundles for details on configuring Bundles and bundlers.

filters

filters is the only configuration option. It allows you to create one or more filters, each which do one of the following:

  1. Permanently remove specified output files from bundle.output.
  2. Run a series of bundlers on a temporarily filtered subset of output files from bundle.output. NOTE: This does not remove anything from bundle.output, the filter only applies temporarily while the configured bundlers run.

filter

Properties:

  • pattern {String|String[]|Function} (required) Use glob pattern(s) to test against each input source path. If the path matches, it will be included in the filter. Or you may pass a custom Function for more flexibility. Custom functions receive file, bundle, and micromatch as parameters, and must return a Boolean to tell Bundles if a file should be added to the filter. For example:
    function myCustomFilter(file, { bundle, micromatch }) {
      // Return `true` to add to filter.
      return true;
    }
    
  • type {string} Default: 'some' micromatch is used to test filter patterns. By default, the micromatch.some() method is used to test. You may tweak the behavior to your liking by passing 'every', 'any', 'all', 'not', or 'contains' to use the corresponding micromatch method.
  • options {Object} Options passed directly to micromatch.
  • reverse {Boolean} When true, files that do NOT match filter.pattern will be added to the filter.
  • bundlers {Object[]} When this property exists, files that match the filter will be run through these bundlers. This is useful to run certain bundlers only on a subset of a larger grouping of files. The bundlers property can be configured exactly like bundlers in bundle.bundlers. See configuring Bundles for more details.

Example:

const bundle = {
  input: [...],
  bundlers: [
    {
      run: require('@bundles/bundles-filters'),
      filters: [
        {
          // These files will be removed permanently.
          pattern: ['!*.yaml'],
        },
        {
          // All other filters will run their matching subset of files through
          // the configured bundlers, after which the original `bundle.output`
          // (minus the removed files) is restored.
          pattern: ['{one,two,three}.md'],
          bundlers: [markdown, footer],
        },
        {
          // Pattern can be a Function.
          pattern: (file, { bundle, micromatch }) => path.extname(file.source.path) === '.css',
          bundlers: [css],
        },
        {
          pattern: ['*.{css,js}', '!three.js'],
          bundlers: [banner, footer],
        },
        {
          pattern: '*.json',
          bundlers: [json],
        },
      ],
    },
  ];
}

Current Tags

  • 0.2.1                                ...           dev (9 months ago)
  • 0.2.1                                ...           latest (9 months ago)

5 Versions

  • 0.2.1                                ...           9 months ago
  • 0.2.0                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 5
Dependencies (2)
Dev Dependencies (7)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |