Add process method (compatibility with optimize-css-assets-webpack-plugin) (#944)
authorstrarsis <strarsis@gmail.com>
Tue, 23 May 2017 11:51:13 +0000 (13:51 +0200)
committerJakub Pawlowicz <contact@jakubpawlowicz.com>
Tue, 23 May 2017 11:51:13 +0000 (13:51 +0200)
lib/clean.js

index 62308ef..7f2d544 100644 (file)
@@ -46,6 +46,20 @@ var CleanCSS = module.exports = function CleanCSS(options) {
   };
 };
 
+
+// for compatibility with optimize-css-assets-webpack-plugin
+CleanCSS.process = function (input, opts) {
+  var optsTo = opts.to;
+  delete opts.to;
+
+  var cleanCss = new CleanCSS(Object.assign({ returnPromise: true, rebaseTo: optsTo }, opts));
+  return cleanCss.minify(input)
+  .then(function(output) {
+    return { css: output.styles };
+  });
+};
+
+
 CleanCSS.prototype.minify = function (input, maybeSourceMap, maybeCallback) {
   var options = this.options;