JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 31327
  • Score
    100M100P100Q157441F
  • License MIT

PostCSS plugin to minify CSS using CSSO

Package Exports

  • postcss-csso

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-csso) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

NPM version Build Status

postcss-csso

PostCSS plugin to minify CSS using CSSO.

Under the hood the plugin converts PostCSS AST into CSSO format, optimises it and converts back. The plugin uses either input PostCSS tree nodes or their clones on reverse convertation. So shape of original PostCSS tree nodes persists the same after compression in most cases (e.g. properties added by other plugins isn't lost). Also this allows to generate source map correctly.

Performance of the plugin is approximately the same as CSSO has (see CSSO numbers in comparison table).

If you have any difficulties with the output of this plugin, please use the CSSO tracker.

Install

npm install postcss-csso

Usage

var postcss = require('postcss');
var csso = require('postcss-csso');

postcss([
    csso
])
    .process('.a { color: #FF0000; } .b { color: rgba(255, 0, 0, 1) }')
    .then(function(result) {
        console.log(result.css);
        // .a,.b{color:red}
    });

Plugin accepts the same options as minify() method of CSSO with no any changes.

postcss([
    csso({ restructure: false })
])
    .process('.a { color: #FF0000; } .b { color: rgba(255, 0, 0, 1) }')
    .then(function(result) {
        console.log(result.css);
        // .a{color:red}.b{color:red}
    });

License

MIT