Skip to content

Minor tweaks and cleanup #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[![NPM version](https://badge.fury.io/js/less-plugin-clean-css.svg)](http://badge.fury.io/js/less-plugin-clean-css) [![Dependencies](https://david-dm.org/less/less-plugin-clean-css.svg)](https://david-dm.org/less/less-plugin-clean-css) [![devDependency Status](https://david-dm.org/less/less-plugin-clean-css/dev-status.svg)](https://david-dm.org/less/less-plugin-clean-css#info=devDependencies) [![optionalDependency Status](https://david-dm.org/less/less-plugin-clean-css/optional-status.svg)](https://david-dm.org/less/less-plugin-clean-css#info=optionalDependencies)
[![NPM version](https://badge.fury.io/js/less-plugin-clean-css.svg)](http://badge.fury.io/js/less-plugin-clean-css) [![Dependencies](https://david-dm.org/less/less-plugin-clean-css.svg)](https://david-dm.org/less/less-plugin-clean-css)

less-plugin-clean-css
=====================
# less-plugin-clean-css

Compresses the css output from less using clean-css.

Expand All @@ -21,7 +20,7 @@ See [clean-css](https://github.com/jakubpawlowicz/clean-css) for the available c

## Programmatic usage

```
```js
var LessPluginCleanCSS = require('less-plugin-clean-css'),
cleanCSSPlugin = new LessPluginCleanCSS({advanced: true});
less.render(lessString, { plugins: [cleanCSSPlugin] })
Expand Down
18 changes: 9 additions & 9 deletions lib/clean-css-processor.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var CleanCSS = require('clean-css'),
usage = require("./usage");
"use strict";

module.exports = function(less) {
var CleanCSS = require("clean-css");

module.exports = function() {
function CleanCSSProcessor(options) {
this.options = options || {};
};
}

CleanCSSProcessor.prototype = {
process: function (css, extra) {
Expand All @@ -24,25 +25,24 @@ module.exports = function(less) {
}
}

if (options.keepSpecialComments === undefined) {
if (typeof options.keepSpecialComments === "undefined") {
options.keepSpecialComments = "*";
}
options.processImport = false;

if (options.rebase === undefined) {
if (typeof options.rebase === "undefined") {
options.rebase = false;
}

if (options.advanced === undefined) {
if (typeof options.advanced === "undefined") {
options.advanced = false;
}

var output = new CleanCSS(options).minify(css);

if (sourceMap) {
if (sourcesContent) {
for(var source = 0; source < sources.length; source++)
{
for (var source = 0; source < sources.length; source++) {
output.sourceMap.setSourceContent(sources[source], sourcesContent[source]);
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"use strict";

var getCleanCSSProcessor = require("./clean-css-processor"),
usage = require("./usage"),
parseOptions = require("./parse-options");

function LessPluginCleanCSS(options) {
this.options = options;
};
}

LessPluginCleanCSS.prototype = {
install: function(less, pluginManager) {
Expand Down
12 changes: 8 additions & 4 deletions lib/parse-options.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
"use strict";

module.exports = function(options) {
if (typeof options === 'string') {
if (typeof options === "string") {
var cleanOptionArgs = options.split(" ");
options = {};
for(var i = 0; i < cleanOptionArgs.length; i++) {

for (var i = 0; i < cleanOptionArgs.length; i++) {
var argSplit = cleanOptionArgs[i].split("="),
argName = argSplit[0].replace(/^-+/,"");
switch(argName) {
argName = argSplit[0].replace(/^-+/, "");

switch (argName) {
case "keep-line-breaks":
case "b":
options.keepBreaks = true;
Expand Down
4 changes: 3 additions & 1 deletion lib/usage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use strict";

module.exports = {
printUsage: function() {
console.log("");
Expand All @@ -14,6 +16,6 @@ module.exports = {
printOptions: function() {
console.log("we support the following arguments... 'keep-line-breaks', 'b'");
console.log("'s0', 's1', 'advanced', 'rebase', 'keepSpecialComments', compatibility', 'rounding-precision'");
console.log("'skip-aggressive-merging', 'skip-shorthand-compacting'")
console.log("'skip-aggressive-merging', 'skip-shorthand-compacting'");
}
};
65 changes: 28 additions & 37 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,39 +1,30 @@
{
"name": "less-plugin-clean-css",
"version": "1.5.1",
"description": "clean-css plugin for less.js",
"homepage": "http://lesscss.org",
"author": {
"name": "Luke Page"
},
"contributors": [
"The Core Less Team"
],
"bugs": {
"url": "https://github.com/less/less-plugin-clean-css/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/less/less-plugin-clean-css.git"
},
"licenses": [
{
"type": "Apache v2",
"url": "https://github.com/less/less-plugin-clean-css/blob/master/LICENSE"
}
],
"main": "lib/index.js",
"engines": {
"node": ">=0.4.2"
},
"dependencies": {
"clean-css": "^3.0.1"
},
"devDependencies": {
},
"keywords": [
"less plugins",
"cleancss",
"less compression"
]
"name": "less-plugin-clean-css",
"version": "1.5.1",
"description": "clean-css plugin for less.js",
"homepage": "http://lesscss.org",
"author": "Luke Page",
"contributors": [
"The Core Less Team"
],
"bugs": {
"url": "https://github.com/less/less-plugin-clean-css/issues"
},
"repository": {
"type": "git",
"url": "git+https://github.com/less/less-plugin-clean-css.git"
},
"license": "Apache-2.0",
"main": "lib/index.js",
"engines": {
"node": ">=0.10"
},
"dependencies": {
"clean-css": "^3.0.1"
},
"keywords": [
"less plugins",
"cleancss",
"less compression"
]
}