postcss-plugin-chain

1.0.0 • Public • Published

postcss-plugin-chain

Utility for chaining multiple PostCSS plugins as a single one.

// Define the plugin:
import chainPlugins from 'postcss-plugin-chain';

const shapesPlugin = chainPlugins('postcss-shapes', [
  require('postcss-circle'),
  require('postcss-triangle'),
]);

// And use it:
postcss([shapesPlugin]);

Installation

yarn add --dev postcss-plugin-chain

Usage

chainPlugins() function accepts 2 parameters: pluginName and pluginsToChain - both pretty self-explanatory.

Returned value is an asynchronous postcss plugin.

Options

If the plugin created with chainPlugins is initialized with options it passes them down to all chained plugins.

If you need to control the options passed to some specific plugins (e.g. map options names or set some defaults), you can wrap the plugin in a function:

const chainedPlugin = chainPlugins('options-example', [
  options => require('postcss-calc')({ ...options, selectors: true }),
  // ...
]);

License

MIT

/postcss-plugin-chain/

    Package Sidebar

    Install

    npm i postcss-plugin-chain

    Weekly Downloads

    141

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    4.14 kB

    Total Files

    5

    Last publish

    Collaborators

    • tsdzw