You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
688 B
24 lines
688 B
/* eslint import/no-extraneous-dependencies: ["error", {"devDependencies": true}] */
|
|
const CleanCSS = require('clean-css');
|
|
|
|
module.exports = (content, options = {}) => {
|
|
// eslint-disable-next-line
|
|
options = Object.assign({
|
|
compatibility: '*,-properties.zeroUnits',
|
|
}, options);
|
|
|
|
return new Promise((resolve, reject) => {
|
|
if (content instanceof Promise) {
|
|
content.then((c) => {
|
|
const minified = new CleanCSS(options).minify(c);
|
|
resolve(minified.styles);
|
|
}).catch((err) => {
|
|
reject(err);
|
|
throw err;
|
|
});
|
|
return;
|
|
}
|
|
const minified = new CleanCSS(options).minify(content);
|
|
resolve(minified.styles);
|
|
});
|
|
};
|
|
|