diff --git a/bin/lessc b/bin/lessc index f9e0b70d..9edcd958 100755 --- a/bin/lessc +++ b/bin/lessc @@ -372,6 +372,21 @@ var parseLessFile = function (e, data) { less.render(data, options) .then(function(css) { if(!options.lint) { + if (options.cleancss) { + var CleanCSS = require('clean-css'); + var cleancssOptions = options.cleancssOptions || {}; + + if (cleancssOptions.keepSpecialComments === undefined) { + cleancssOptions.keepSpecialComments = "*"; + } + cleancssOptions.processImport = false; + cleancssOptions.noRebase = true; + if (cleancssOptions.noAdvanced === undefined) { + cleancssOptions.noAdvanced = true; + } + + css = new CleanCSS(cleancssOptions).minify(css); + } if (output) { ensureDirectory(output); fs.writeFileSync(output, css, 'utf8'); diff --git a/lib/less/contexts.js b/lib/less/contexts.js index 269048ae..c79349e4 100644 --- a/lib/less/contexts.js +++ b/lib/less/contexts.js @@ -69,11 +69,9 @@ var evalCopyProperties = [ 'silent', // whether to swallow errors and warnings 'verbose', // whether to log more activity 'compress', // whether to compress - 'yuicompress', // whether to compress with the outside tool yui compressor 'ieCompat', // whether to enforce IE compatibility (IE8 data-uri) 'strictMath', // whether math has to be within parenthesis 'strictUnits', // whether units need to evaluate correctly - 'cleancss', // whether to compress with clean-css 'sourceMap', // whether to output a source map 'importMultiple', // whether we are currently importing multiple copies 'urlArgs', // whether to add args into url tokens diff --git a/lib/less/environment/browser.js b/lib/less/environment/browser.js index 85a9f646..2e045c73 100644 --- a/lib/less/environment/browser.js +++ b/lib/less/environment/browser.js @@ -44,8 +44,6 @@ return { alwaysMakePathsAbsolute: function alwaysMakePathsAbsolute() { return true; }, - getCleanCSS: function () { - }, supportsDataURI: function() { return false; }, diff --git a/lib/less/environment/node.js b/lib/less/environment/node.js index 884f6eb8..9c2f8e98 100644 --- a/lib/less/environment/node.js +++ b/lib/less/environment/node.js @@ -23,9 +23,6 @@ module.exports = { readFileSync: function (filename) { return require("fs").readFileSync(filename); }, - getCleanCSS: function() { - return require('clean-css'); - }, getPath: function (env, filename) { var j = filename.lastIndexOf('/'); if (j < 0) { diff --git a/lib/less/parser/parser.js b/lib/less/parser/parser.js index d870c8fc..6d19dd9c 100644 --- a/lib/less/parser/parser.js +++ b/lib/less/parser/parser.js @@ -176,21 +176,7 @@ var Parser = function Parser(env) { throw new LessError(parser, e, env); } - var CleanCSS = environment.getCleanCSS(); - if (options.cleancss && CleanCSS) { - var cleancssOptions = options.cleancssOptions || {}; - - if (cleancssOptions.keepSpecialComments === undefined) { - cleancssOptions.keepSpecialComments = "*"; - } - cleancssOptions.processImport = false; - cleancssOptions.noRebase = true; - if (cleancssOptions.noAdvanced === undefined) { - cleancssOptions.noAdvanced = true; - } - - return new CleanCSS(cleancssOptions).minify(css); - } else if (options.compress) { + if (options.compress) { return css.replace(/(^(\s)+)|((\s)+$)/g, ""); } else { return css;