UNPKG

450 BJavaScriptView Raw
1var CleanCSS = require("clean-css");
2var assign = require("lodash/assign");
3
4module.exports = function(source, options) {
5 var opts = assign({}, options && options.cleanCSSOptions, {
6 returnPromise: true
7 });
8
9 if(options.sourceMaps) {
10 opts.sourceMap = source.map ? source.map+"" : true;
11 }
12
13 return new CleanCSS(opts)
14 .minify(source.code)
15 .then(function(result) {
16 return {
17 code: result.styles,
18 map: result.sourceMap
19 };
20 });
21};