postcss-composes-enhanced

Enhance the composes behavior in CSS Modules

Usage no npm install needed!

<script type="module">
  import postcssComposesEnhanced from 'https://cdn.skypack.dev/postcss-composes-enhanced';
</script>

README

PostCSS Composes Enhanced PostCSS

NPM Version Build Status Support Chat

PostCSS Composes Enhanced lets you enhance the composes behavior in CSS Modules.

.example {
  @composes no-margin from '@company/layout';
}

/* becomes */

.example {
  composes: no-margin from '../../node_modules/@company/layout/index.module.css';
}

Usage

Add PostCSS Composes Enhanced to your project:

npm install postcss-composes-enhanced --save-dev

Use PostCSS Composes Enhanced to process your CSS:

const composesEnhanced = require('postcss-composes-enhanced')

composesEnhanced.process(YOUR_CSS /*, processOptions, pluginOptions */)

Or use it as a PostCSS plugin:

const postcss = require('postcss')
const composesEnhanced = require('postcss-composes-enhanced')

postcss([composesEnhanced(/* pluginOptions */)]).process(YOUR_CSS /*, processOptions */)

PostCSS Composes Enhanced runs in all Node environments, with special instructions for:

Node PostCSS CLI Webpack Create React App Gulp Grunt

Options

resolveImports

The resolveImports option determines whether imports within composes declarations should be resolved.

transformAtRules

The transformAtRules option determines whether @composes at-rules should be transformed into declarations.

Additional Options

Additional options will be passed through into css-import-resolve.