Socket
Socket
Sign inDemoInstall

grunt-less-browserify

Package Overview
Dependencies
72
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    grunt-less-browserify

LESS precompiler and CSS plugin for grunt-browserify


Version published
Maintainers
1
Install size
22.4 MB
Created

Readme

Source

grunt-less-browserify Build Status

Version 0.0.1

LESS precompiler and CSS plugin for grunt-browserify. Forked from node-lessify.

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 grunt-less-browserify

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');

Grunt Configuration

module.exports = function(grunt) {
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    browserify: {
      dist: {
        files: {
          'build.js': ['main.js']
        },
        options: {
            transform: ['grunt-less-browserify'],
        }
      }
    },
    lessBrowserify: {
        imports: ['helpers.less'],
        output:  'dist/word.css',
        jsAppend: false
    }
  });
};

Options

  • imports: A list of files that should be imported before compiling every less file. This is very useful for less helper libraries.
  • output: An output file for the concatenated stylesheet.
  • jsAppend: Whether or not to add the stylesheets using javascript in the browserify output. (default true)
  • minify: Whether or not to minify the CSS output. Defaults to true unless specified false.

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.

Keywords

FAQs

Last updated on 07 Mar 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc