Novice, Practiced, Mastered
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

clean-css-promise

2.1.0 • Public • Published

clean-css-promise

npm version Build Status Coverage Status

clean-css with the default Promise interface and some improvements

const CleanCssPromise = require('clean-css-promise');
 
new CleanCssPromise()
.minify('p { margin: 1px 1px 1px 1px; }')
.then(({styles}) => console.log(styles)) //=> p{margin:1px}

Installation

Use npm.

npm install clean-css-promise

API

const CleanCssPromise = require('clean-css-promise');

class CleanCssPromise([options])

options: Object (clean-css constructor options)

Almost the same the original clean-css, except for:

  • returnPromise option is enabled by default, and cannot be disabled.
  • onRejected function receives an error instead of an array.
  • All problems that clean-css considers as warnings, for example broken CSS syntax, are regarded as errors.
const CleanCssPromise = require('clean-css-promise');
 
new CleanCssPromise({})
.minify('@import url(/foo);}')
.catch(err => {
  err.message;
  /*=> `2 errors found while optimizing CSS with clean-css:
  1. Ignoring local @import of "/foo" as resource is missing.
  2. Invalid character(s) '?' at 1:18. Ignoring.
 
clean-css dangerously ignores these errors but clean-css-promise doesn't, because it's much more reasonable to update the CSS to fix all problems than to pretend that you didn't see the errors.` */
});

License

ISC License © 2017 Shinnosuke Watanabe

install

npm i clean-css-promise

Downloadsweekly downloads

25,249

version

2.1.0

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability