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.3 to 0.0.4

test/app/debug.js

26

index.js

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

// v0.0.4
var less = require('less');

@@ -6,7 +8,18 @@ var CleanCSS = require('clean-css');

var func_start = "(function() { var head = document.getElementsByTagName('head')[0]; style = document.createElement('style'); style.type = 'text/css';";
var func_end = "if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); } head.appendChild(style);}())";
var textMode = false,
func_start = "(function() { var head = document.getElementsByTagName('head')[0]; 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 = {};
};
if (options.browserify && options.browserify["transform-options"] && options.browserify["transform-options"]["node-lessify"] == "textMode") {
textMode = true;
}
module.exports = function(file) {
if (!/\.css|\.less/.test(file)) {
if (!/\.css$|\.less$/.test(file)) {
return through();

@@ -39,4 +52,7 @@ }

compiled = func_start + "var css = \"" + compiled.replace(/'/g, "\\'").replace(/"/g, '\\"') + "\";" + func_end;
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);

@@ -43,0 +59,0 @@ return this.queue(null);

4

package.json
{
"name": "node-lessify",
"version": "0.0.3",
"version": "0.0.4",
"description": "LESS precompiler and CSS plugin for Browserify v2",
"main": "index.js",
"scripts": {
"test": "test/test.js"
"test": "test/test.js && cd test/app && browserify -t ../../index debug.js > script.js"
},

@@ -9,0 +9,0 @@ "repository": {

@@ -38,2 +38,14 @@ node-lessify [![Build Status](https://travis-ci.org/wilson428/node-lessify.png)](https://travis-ci.org/wilson428/node-lessify)

## Imports
LESS allows one to ```@import``` other LESS files. This module synchronously imports those dependencies at the time of the bundling. It looks for the imported files in both the directory of the parent file and the folder where the module itself lives, so it should work so long as the paths in the ```@import``` commands are correct relative to the importing file, as usual. It is not currently tested for recursive importing.
LESS allows one to ```@import``` other LESS files. This module synchronously imports those dependencies at the time of the bundling. It looks for the imported files in both the directory of the parent file and the folder where the module itself lives, so it should work so long as the paths in the ```@import``` commands are correct relative to the importing file, as usual. It is not currently tested for recursive importing.
## 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:
"browserify": {
"transform": ["node-lessify"],
"transform-options": {
"node-lessify": "textMode"
}
}
See the dummy app in the [test directory](/test) for an example of this in action.

@@ -20,4 +20,3 @@ #!/usr/bin/env node

}
fs.writeFile(__dirname + "/bundle.js", src);
assert.ok(src);
});

Sorry, the diff of this file is not supported yet

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