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.8 to 0.0.9-a

51

index.js

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

// v0.0.8
// v0.0.9a

@@ -6,13 +6,8 @@ var path = require("path");

var less = require('less');
var assign = require('object-assign');
var textMode = false,
func_start = "(function() { var head = document.getElementsByTagName('head')[0]; style = document.createElement('style'); style.type = 'text/css';",
func_start = "(function() { var head = document.getElementsByTagName('head')[0]; var style = document.createElement('style'); style.type = 'text/css';",
func_end = "if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style);}())";
try {
var options = require(process.cwd() + "/package.json");
} catch (e) {
var options = {};
};
/*

@@ -25,4 +20,17 @@ you can pass options to the transform from your package.json file like so:

}
NOTE: This is deprecated since it is now possible to do this like so:
"browserify": {
"transform": [
[ "node-lessify", { "textMode": true } ]
]
}
*/
try {
var options = require(process.cwd() + "/package.json");
} catch (e) {
var options = {};
};
/*

@@ -36,3 +44,3 @@ 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

module.exports = function(file) {
module.exports = function(file, package_options) {
if (!/\.css$|\.less$/.test(file)) {

@@ -42,2 +50,9 @@ return through();

// supplement options with those from package
for (var key in package_options) {
if (package_options.hasOwnProperty(key) && key !== "_flags") {
options[key] = package_options[key];
}
}
var buffer = "", mydirName = path.dirname(file);

@@ -56,6 +71,8 @@

// CSS is LESS so no need to check extension
less.render(buffer, {
less.render(buffer, assign({
paths: [".", mydirName],
compress: true
}, function(e, output) {
}, {
plugins: package_options.plugins ? package_options.plugins : undefined
}), function(e, output) {
if (e) {

@@ -73,13 +90,7 @@ var msg = e.message;

console.error("node-lessify encountered an error when compiling", file);
console.error("Error: ", msg);
throw new Error(msg, file, e.line);
//self.emit('error');
done();
done(new Error(msg, file, e.line));
}
compiled = output.css;
if (textMode) {
if (textMode || package_options.textMode) {
compiled = "module.exports = \"" + compiled.replace(/'/g, "\\'").replace(/"/g, '\\"') + "\";";

@@ -95,2 +106,2 @@ } else {

}
};
};
{
"name": "node-lessify",
"version": "0.0.8",
"version": "0.0.9a",
"description": "LESS precompiler and CSS plugin for Browserify",

@@ -21,13 +21,15 @@ "main": "index.js",

"author": {
"name" : "Chris Wilson",
"email" : "wilson@mechanicalscribe.com",
"url" : "http://mechanicalscribe.com"
"name": "Chris Wilson",
"email": "wilson@mechanicalscribe.com",
"url": "http://mechanicalscribe.com"
},
"license": "MIT",
"dependencies": {
"through2": "0.6.x",
"less": "2.0.x"
"less": "2.4.x",
"object-assign": "^2.0.0",
"through2": "0.6.x"
},
"devDependencies": {
"browserify": "6.x.x"
"browserify": "8.x.x",
"less-plugin-autoprefix": "^1.3.0"
},

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

node-lessify
============
Version 0.0.8
Version 0.0.9a

@@ -42,3 +42,5 @@ [![Build Status](https://travis-ci.org/wilson428/node-lessify.png)](https://travis-ci.org/wilson428/node-lessify)

## Text Mode
##Options
###Text Mode
[As requested](https://github.com/wilson428/node-lessify/issues/1), it is now possible to ask the transformation not to auto-append the css but merely to compile it into a string and assign it to a variable. This is accomplished by adding a `package.json` file in the directory from which browserify is run with the following properties:

@@ -55,6 +57,22 @@

###Plugins
You can pass a `plugins` argument to get less plugins like [autoprefix](https://www.npmjs.com/package/less-plugin-autoprefix):
For example (from [test.js](test/test.js)):
var LessPluginAutoPrefix = require('less-plugin-autoprefix');
var autoprefix= new LessPluginAutoPrefix({ browsers: ["last 2 versions"] });
var b = browserify(sampleLESS);
b.transform(lessify, {plugins: [autoprefix] });
## Changes
**v0.0.9a**: Allow for less plugins. Thx @henriklundgren!
**v0.0.9**: Read options from package.json the correct way, now that [Browserify allows for it](https://github.com/substack/node-browserify#btransformtr-opts).
**v0.0.8**: More useful error statements with line and column numbers
**v0.0.7**: Now throws an error instead of failing silently if there's bad LESS, per [Issue #8](https://github.com/wilson428/node-lessify/issues/8)

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

var LessPluginAutoPrefix = require('less-plugin-autoprefix');
var autoprefix= new LessPluginAutoPrefix({ browsers: ["last 2 versions"] });
var b = browserify(sampleLESS);
//b.add(sampleLESS);
//b.add(sampleCSS);
b.transform(lessify);
b.transform(lessify, {plugins: [autoprefix] });

@@ -24,2 +27,2 @@ b.bundle(function (err, src) {

fs.writeFileSync(__dirname + "/bundle.js", src.toString());
});
});

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