Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including postcss-modules-extract-imports with all npm packages installed. Try it out:

var postcssModulesExtractImports = require("postcss-modules-extract-imports")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

postcss-modules-extract-imports v2.0.0

A CSS Modules transform to extract local aliases for inline imports

CSS Modules: Extract Imports

Build Status

Transforms:

:local(.continueButton) {
  composes: button from "library/button.css";
  color: green;
}

into:

:import("library/button.css") {
  button: __tmp_487387465fczSDGHSABb;
}
:local(.continueButton) {
  composes: __tmp_487387465fczSDGHSABb;
  color: green;
}

Specification

  • Only a certain whitelist of properties are inspected. Currently, that whitelist is ['composes'] alone.
  • An extend-import has the following format:
composes: className [... className] from "path/to/file.css";

Options

  • failOnWrongOrder bool generates exception for unpredictable imports order.
.aa {
  composes: b from './b.css';
  composes: c from './c.css';
}

.bb {
  /* "b.css" should be before "c.css" in this case */
  composes: c from './c.css';
  composes: b from './b.css';
}

Building

npm install
npm test

Build Status

  • Lines: Coverage Status
  • Statements: codecov.io

Development

  • npm watch will watch src for changes and rebuild
  • npm autotest will watch src and test for changes and retest

License

ISC

With thanks

  • Mark Dalgleish
  • Tobias Koppers
  • Guy Bedford

Glen Maddern, 2015.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free