LESS precompiler and CSS plugin for Browserify v2
npm install node-lessify-sauce
|1||downloads in the last month|
|Version||0.0.4 last updated 3 months ago|
|Keywords||less, css, browserify|
|Dependencies||through, less, clean-css, path|
LESS precompiler and CSS plugin for Browserify v2. Inspired by node-underscorify.
When bundling an app using Browserify, 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.
This small script allows you to
require() your CSS or LESS files as you would any other script.
npm install node-lessify
Write your LESS or CSS files as you normally would, and put them somewhere where your script can find it.
Then simply require them as you might anything else:
To compile the stylesheets, pass this module to browserify as a transformation on the command line.
browserify -t node-lessify script.js > bundle.js
How it works
The stylesheets are compiled (in the case of LESS), minified, and bundle into a function that creates a new
<style> element and appends it to the
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.