Package Exports
- clean-css-promise
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 (clean-css-promise) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
clean-css-promise
clean-css with the default Promise interface and some improvements
const CleanCssPromise = require('clean-css-promise');
(async () => {
const {styles} = await new CleanCssPromise().minify(`
p {
color: #ff0000;
}
b {
/* nothing */
}
`); //=> 'p{color:red}'
})();Installation
npm install clean-css-promiseAPI
const CleanCssPromise = require('clean-css-promise');class CleanCssPromise([options])
options: Object (clean-css constructor options)
Almost the same the original clean-css, except for:
returnPromiseoption is enabled by default, and cannot be disabled.- onRejected function receives an
Errorinstead of anArray. - 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 - 2019 Watanabe Shinnosuke