1.0.0 • Published 5 years ago

postcss-plugin-chain v1.0.0

Weekly downloads
2,147
License
MIT
Repository
github
Last release
5 years ago

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