sauce-lessify

0.0.5 • Public • Published

sauce-lessify

Version 0.0.3

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.

Installation

npm install sauce-lessify

Usage

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:

var cssFromLess = require('./styles.less');
var css         = require('./styles.css');

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 <head> using native Javascript.

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.

Readme

Keywords

Package Sidebar

Install

npm i sauce-lessify

Weekly Downloads

0

Version

0.0.5

License

MIT

Last publish

Collaborators

  • chrishoughton