Skip to content

Broccoli plugin to transform one or more input files using PostCSS to one or more output files.

License

Notifications You must be signed in to change notification settings

buschtoens/broccoli-multi-postcss

Repository files navigation

broccoli-multi-postcss

Build Status npm version Download Total code style: prettier Dependabot enabled dependencies Status devDependencies Status

Broccoli plugin to transform one or more input files using PostCSS to one or more output files.

It's like broccoli-postcss, but allows you consume more than once input file at once. It also allows you to generate additional secondary output files.

Installation

yarn add broccoli-multi-postcss

Usage

import BroccoliMultiPostCSS from 'broccoli-multi-postcss';
import { plugin } from 'postcss';

const myPlugin = plugin('selector-metadata', options => {
  return (root, result) => {
    const selectors: string[] = [];
    root.walkRules(rule => {
      selectors.push(rule.selector);
    });

    const metadata = { selectors, fileName: result.opts.to };

    result.messages.push({
      type: BroccoliMultiPostCSS.MessageType.WriteFile,
      plugin: 'selector-metadata',
      path: `${result.opts.to}.meta.json`,
      content: JSON.stringify(metadata)
    });
  };
});

const tree = new BroccoliMultiPostCSS(['./styles'], { plugins: [myPlugin] });

About

Broccoli plugin to transform one or more input files using PostCSS to one or more output files.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published