Socket
Socket
Sign inDemoInstall

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

LESS precompiler and CSS plugin for Browserify v2


Version published
Weekly downloads
709
increased by27.52%
Maintainers
1
Weekly downloads
 
Created
Source

node-lessify

Version 0.0.5

Build Status

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 node-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:

require('./styles.less');
require('./mysite.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.

Text Mode

As requested, 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 for an example of this in action.

Keywords

FAQs

Package last updated on 10 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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