css-flatten
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

CSS Flatten

Flattens a nested (S)CSS string, & placeholders are supported too.

This is implemented using css-simple-parser, which makes it tiny and blazing fast, but there are some limitations to be aware of, read the parser's readme to learn about them.

Install

npm install --save css-flatten

Usage

import flatten from 'css-flatten';

const css = `
.foo {
  color: red;
  &:hover {
    color: green;
  }
  .bar {
    color: blue;
  }
}
`;

flatten ( css ); // =>
// .foo {
//   color: red;
// }
// .foo:hover {
//   color: green;
// }
// .foo .bar {
//   color: blue;
// }

License

MIT © Fabio Spampinato

Dependents (2)

Package Sidebar

Install

npm i css-flatten

Weekly Downloads

274

Version

2.0.0

License

none

Unpacked Size

26 kB

Total Files

14

Last publish

Collaborators

  • fabiospampinato