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

node-lessify

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-lessify - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

76

index.js

@@ -1,7 +0,6 @@

// v0.0.4
// v0.0.6
var path = require("path");
var through = require('through2');
var less = require('less');
var CleanCSS = require('clean-css');
var through = require('through');
var path = require("path");

@@ -18,2 +17,15 @@ var textMode = false,

/*
you can pass options to the transform from your package.json file like so:
"browserify": {
"transform-options": {
"node-lessify": "textMode"
}
}
*/
/*
textMode simply compiles the LESS into a single string of CSS and passes it back without adding the code that automatically appends that CSS to the page
*/
if (options.browserify && options.browserify["transform-options"] && options.browserify["transform-options"]["node-lessify"] == "textMode") {

@@ -27,35 +39,37 @@ textMode = true;

}
var buffer = "",
mydirName = path.dirname(file);
var parser = new(less.Parser)({
paths: [mydirName, __dirname],
syncImport: true
});
var buffer = "", mydirName = path.dirname(file);
return through(function(chunk) {
return buffer += chunk.toString();
}, function() {
return through(write, end);
var compiled;
function write(chunk, enc, next) {
buffer += chunk.toString();
next();
}
// CSS is LESS so no need to check extension
parser.parse(buffer, function(e, r) {
compiled = r.toCSS();
});
function end(done) {
var self = this;
// rv comments
// http://stackoverflow.com/questions/5989315/regex-for-match-replacing-javascript-comments-both-multiline-and-inline
compiled = compiled.replace(/(?:\/\*(?:[\s\S]*?)\*\/)|(?:([\s;])+\/\/(?:.*)$)/gm, "");
try {
// CSS is LESS so no need to check extension
less.render(buffer, {
paths: [".", mydirName],
compress: true
}, function(e, output) {
compiled = output.css;
if (textMode) {
compiled = "module.exports = \"" + compiled.replace(/'/g, "\\'").replace(/"/g, '\\"') + "\";";
} else {
compiled = func_start + "var css = \"" + compiled.replace(/'/g, "\\'").replace(/"/g, '\\"') + "\";" + func_end;
}
var compiled = CleanCSS().minify(compiled);
if (textMode) {
compiled = "module.exports = \"" + compiled.replace(/'/g, "\\'").replace(/"/g, '\\"') + "\";";
} else {
compiled = func_start + "var css = \"" + compiled.replace(/'/g, "\\'").replace(/"/g, '\\"') + "\";" + func_end;
}
this.queue(compiled);
return this.queue(null);
});
self.push(compiled);
self.push(null);
done();
});
} catch (error) {
self.emit('error', (error instanceof Error) ? error : new Error(error));
done();
}
}
};
{
"name": "node-lessify",
"version": "0.0.5",
"description": "LESS precompiler and CSS plugin for Browserify v2",
"version": "0.0.6",
"description": "LESS precompiler and CSS plugin for Browserify",
"main": "index.js",

@@ -26,8 +26,7 @@ "scripts": {

"dependencies": {
"through": "^2.2.7",
"less": "^1.5.0",
"clean-css": "2.0.2"
"through2": "0.6.x",
"less": "2.0.x"
},
"devDependencies": {
"browserify": "^6.0.0"
"browserify": "6.x.x"
},

@@ -34,0 +33,0 @@ "bugs": {

node-lessify
============
Version 0.0.5
Version 0.0.6
[![Build Status](https://travis-ci.org/wilson428/node-lessify.png)](https://travis-ci.org/wilson428/node-lessify)
LESS precompiler and CSS plugin for Browserify v2. Inspired by [node-underscorify](https://github.com/maxparm/node-underscorify).
LESS 2.0 precompiler and CSS plugin for Browserify v2. Inspired by [node-underscorify](https://github.com/maxparm/node-underscorify).

@@ -9,0 +9,0 @@ When bundling an app using [Browserify](http://browserify.org/), it's often convenient to be able to include your CSS as a script that appends the style declarations to the head. This is particularly relevant for self-assembling apps that attach themselves to a page but otherwise have reserved real-estate on the DOM.

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

var css = require("./styles.css");
var css = require("../styles.css");
var less = require("../styles.less");
console.log(css);
console.log(css);
console.log(less);

@@ -11,5 +11,5 @@ #!/usr/bin/env node

var b = browserify();
b.add(sampleLESS);
b.add(sampleCSS);
var b = browserify(sampleLESS);
//b.add(sampleLESS);
//b.add(sampleCSS);
b.transform(lessify);

@@ -19,5 +19,7 @@

if (err) {
console.error(err);
assert.fail(err);
}
assert.ok(src);
fs.writeFileSync(__dirname + "/bundle.js", src.toString());
});
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