node-lessify
Advanced tools
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10755
130
77
3
2
1
+ Addedobject-assign@^2.0.0
+ Addedajv@6.12.6(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addederrno@0.1.8(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addedimage-size@0.3.5(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedless@2.4.0(transitive)
+ Addedmime@1.6.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedobject-assign@2.1.1(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpromise@6.1.0(transitive)
+ Addedprr@1.0.1(transitive)
+ Addedpsl@1.10.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsource-map@0.2.0(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
- Removedasn1@0.1.11(transitive)
- Removedassert-plus@0.1.5(transitive)
- Removedasync@0.9.2(transitive)
- Removedaws-sign2@0.5.0(transitive)
- Removedbl@0.9.5(transitive)
- Removedboom@0.4.2(transitive)
- Removedcaseless@0.6.0(transitive)
- Removedcombined-stream@0.0.7(transitive)
- Removedcryptiles@0.2.2(transitive)
- Removedctype@0.5.3(transitive)
- Removeddelayed-stream@0.0.5(transitive)
- Removedforever-agent@0.5.2(transitive)
- Removedform-data@0.1.4(transitive)
- Removedhawk@1.1.1(transitive)
- Removedhoek@0.9.1(transitive)
- Removedhttp-signature@0.10.1(transitive)
- Removedless@2.0.0(transitive)
- Removedmime@1.2.11(transitive)
- Removedmime-types@1.0.2(transitive)
- Removednode-uuid@1.4.8(transitive)
- Removedoauth-sign@0.4.0(transitive)
- Removedpromise@6.0.1(transitive)
- Removedqs@2.3.3(transitive)
- Removedrequest@2.47.0(transitive)
- Removedsntp@0.2.4(transitive)
- Removedsource-map@0.1.43(transitive)
- Removedstringstream@0.0.6(transitive)
- Removedtldts@6.1.61(transitive)
- Removedtldts-core@6.1.61(transitive)
- Removedtough-cookie@5.0.0(transitive)
- Removedtunnel-agent@0.4.3(transitive)
Updatedless@2.4.x