Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

less-plugin-clean-css

Package Overview
Dependencies
Maintainers
3
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

less-plugin-clean-css - npm Package Compare versions

Comparing version 1.5.1 to 1.6.0

.editorconfig

33

lib/clean-css-processor.js

@@ -1,12 +0,13 @@

var CleanCSS = require('clean-css'),
usage = require("./usage");
"use strict";
module.exports = function(less) {
const CleanCSS = require("clean-css");
module.exports = function () {
function CleanCSSProcessor(options) {
this.options = options || {};
};
}
CleanCSSProcessor.prototype = {
process: function (css, extra) {
var options = this.options,
let options = this.options,
sourceMap = extra.sourceMap,

@@ -19,3 +20,4 @@ sources,

if (options.sourceMap) {
var sourceMapObj = JSON.parse(options.sourceMap);
options.sourceMap = options.sourceMap.toString();
const sourceMapObj = JSON.parse(options.sourceMap);
if (sourceMapObj.sourcesContent) {

@@ -28,3 +30,3 @@ sourcesContent = sourceMapObj.sourcesContent;

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

@@ -34,16 +36,15 @@ }

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);
const output = new CleanCSS(options).minify(css);
if (sourceMap) {
if (sourcesContent) {
for(var source = 0; source < sources.length; source++)
{
for (let source = 0; source < sources.length; source++) {
output.sourceMap.setSourceContent(sources[source], sourcesContent[source]);

@@ -55,9 +56,9 @@ }

var css = output.styles;
let outputCSS = output.styles;
if (sourceMap) {
var sourceMapURL = sourceMap.getSourceMapURL();
css += sourceMap.getCSSAppendage();
const sourceMapURL = sourceMap.getSourceMapURL();
outputCSS += sourceMap.getCSSAppendage();
}
return css;
return outputCSS;
}

@@ -64,0 +65,0 @@ };

@@ -1,2 +0,4 @@

var getCleanCSSProcessor = require("./clean-css-processor"),
"use strict";
const getCleanCSSProcessor = require("./clean-css-processor"),
usage = require("./usage"),

@@ -7,7 +9,7 @@ parseOptions = require("./parse-options");

this.options = options;
};
}
LessPluginCleanCSS.prototype = {
install: function(less, pluginManager) {
var CleanCSSProcessor = getCleanCSSProcessor(less);
install: function (less, pluginManager) {
const CleanCSSProcessor = getCleanCSSProcessor(less);
pluginManager.addPostProcessor(new CleanCSSProcessor(this.options));

@@ -18,3 +20,3 @@ },

},
setOptions: function(options) {
setOptions: function (options) {
this.options = parseOptions(options);

@@ -21,0 +23,0 @@ },

@@ -1,9 +0,13 @@

module.exports = function(options) {
if (typeof options === 'string') {
var cleanOptionArgs = options.split(" ");
"use strict";
module.exports = function (options) {
if (typeof options === "string") {
const cleanOptionArgs = options.split(" ");
options = {};
for(var i = 0; i < cleanOptionArgs.length; i++) {
var argSplit = cleanOptionArgs[i].split("="),
argName = argSplit[0].replace(/^-+/,"");
switch(argName) {
for (let i = 0; i < cleanOptionArgs.length; i++) {
const argSplit = cleanOptionArgs[i].split("="),
argName = argSplit[0].replace(/^-+/, "");
switch (argName) {
case "keep-line-breaks":

@@ -20,3 +24,3 @@ case "b":

case "keepSpecialComments":
var specialCommentOption = argSplit[1];
let specialCommentOption = argSplit[1];
if (specialCommentOption !== "*") {

@@ -23,0 +27,0 @@ specialCommentOption = Number(specialCommentOption);

@@ -0,3 +1,5 @@

"use strict";
module.exports = {
printUsage: function() {
printUsage: function () {
console.log("");

@@ -14,7 +16,7 @@ console.log("Clean CSS Plugin");

},
printOptions: function() {
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'");
}
};
{
"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"
},
"name": "less-plugin-clean-css",
"version": "1.6.0",
"description": "clean-css plugin for less.js",
"homepage": "https://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": "5.3.3"
},
"keywords": [
"less plugins",
"cleancss",
"less compression"
],
"devDependencies": {
"less": "4.2.0",
"mocha": "10.4.0"
},
"keywords": [
"less plugins",
"cleancss",
"less compression"
]
"scripts": {
"test": "mocha"
}
}

@@ -1,11 +0,22 @@

[![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)
<p align="center">
<a href="https://github.com/less/less-plugin-clean-css/actions?query=branch%3Amaster"><img src="https://github.com/less/less-plugin-clean-css/actions/workflows/build.yml/badge.svg?branch=master" alt="Github Actions CI"/></a>
<a href="https://www.npmtrends.com/less-plugin-clean-css"><img src="https://img.shields.io/npm/dm/less-plugin-clean-css.svg?sanitize=true" alt="Downloads"></a>
<a href="https://www.npmjs.com/package/less-plugin-clean-css"><img src="https://img.shields.io/npm/v/less-plugin-clean-css.svg?sanitize=true" /></a>
</p>
less-plugin-clean-css
=====================
# less-plugin-clean-css
Compresses the css output from less using clean-css.
Compresses the css output from less using [clean-css](https://github.com/jakubpawlowicz/clean-css).
## lessc usage
First of all install less via
```bash
npm install -g less
```
then install the `less-plugin-clean-css`
```bash
npm install -g less-plugin-clean-css

@@ -16,15 +27,17 @@ ```

```
```bash
lessc file.less --clean-css="--s1 --advanced --compatibility=ie8"
```
See [clean-css](https://github.com/jakubpawlowicz/clean-css) for the available command options - the only differences are `advanced` and `rebase` which we default to false, because it is not always entirely safe.
See [clean-css](https://github.com/jakubpawlowicz/clean-css/tree/v3.0.1#how-to-use-clean-css-programmatically) for the
available command options - the only differences are `advanced` and `rebase` which we default to false, because it is
not always entirely safe.
## Programmatic usage
```
```js
var LessPluginCleanCSS = require('less-plugin-clean-css'),
cleanCSSPlugin = new LessPluginCleanCSS({advanced: true});
less.render(lessString, { plugins: [cleanCSSPlugin] })
.then(
less.render(lessString, {plugins: [cleanCSSPlugin]})
.then(
```

@@ -31,0 +44,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc