
Compile LESS to CSS, with options for creating 'bundles', individual components, themes or whatever makes you happy.
This project just launched so expect frequent changes. And if you find this project interesting please consider starring it to receive updates.
assemble-less has many more features than we've been able to document thus far. So while we work to improve the docs, please let us know if you have any questions or have any trouble getting assemble-less to work. And feel free to create an Issue, we're here to help.
Table of Contents
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to read the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins.
Then install the required local dependencies and this plugin with this command:
$ npm install
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('assemble-less');
When completed, you'll be able to run the various grunt commands provided:
grunt lessRuns the Less.js compiler to rebuild the specified /test/fixtures/*.less files. Requires Less.js and assemble-less.
grunt watchThis is a convenience task to "Run predefined tasks whenever watched file patterns are added, changed or deleted". Requires grunt-contrib-watch, npm i grunt-contrib-watch.
Should you encounter problems with installing dependencies or running the grunt commands, be sure to first uninstall any previous versions (global and local) you may have installed, and then rerun npm install.
In your project's Gruntfile, add a section named assemble to the data object passed into grunt.initConfig().
grunt.initConfig({
less: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific file lists and/or options go here.
}
}
});
grunt.loadNpmTasks('assemble-less');
grunt.registerTask('default', [
'jshint',
'less'
]);
Task targets, files and options may be specified according to the grunt Configuring tasks guide.
Options developed specifically for the
assemble-lessplugin
Type: String
Default: less
Specify the path to the Less.js version that you wish to use for compiling to CSS. Useful for testing to see if one version produces different output than another.
Type: String
Default value: null
A convenience option for externalizing task options into a .lessrc file. If this file is specified, options defined therein will be used.
less: {
options: grunt.file.readJSON('.lessrc')
}
The .lessrc file must be valid JSON and looks something like this:
{
"require": null,
"concat": false,
"compress": false,
"yuicompress": false,
"optimization": 03,
"strictImports": true,
"dumpLineNumbers": false,
"strictMaths": false,
"strictUnits": false
}
Type: String|Array
Default: empty string
Specified files will be prepended to the beginning of src files, not to the concatenated output. This feature is useful for "inlining" globaly-required LESS files, such as variables or mixins, so that they do not need to be referenced with @import statements inside any individual files.
Type: Boolean
Default: true
Concatenate all source files by default. If you change the value to false, all source files will compile into individual files.
Type: Object
Default: null
Data object for defining global variables inside the Gruntfile which will be accessible in LESS files.
These options will be passed through directly to Less.js
See the Less.js documentation for more info about supported options.
Type: String|Array
Default: Directory of input files
Specifies directories to scan for @import directives when parsing. The default value is the directory of the specified source files. In other words, the paths option allows you to specify paths for your @import statements in the less task as an alternative to specifying a path on every @import statement that appears throughout your LESS files. So instead of doing this:
@import "path/to/my/less/files/mixins/mixins.less";
you can do this:
@import "mixins.less";
Type: Boolean
Default: false
Specifies if we should compress the compiled css by removing some whitespaces.
Type: Boolean
Default: false
Compress output using cssmin.js.
Type: Integer
Default: null
Set the parser's optimization level. The lower the number, the less nodes it will create in the tree. This could matter for debugging, or if you want to access the individual nodes in the tree.
Type: Boolean
Default: false
Force evaluation of imports.
Type: Boolean
Default: true
Force operations to be enclosed within parenthesis, (2 / 6).
Type: Boolean
Default: true
Force strict evaluation of units. If set to false the compiler will not throw an error with operations such as (3 * 1em).
Type: String
Default: false
Configures -sass-debug-info support.
Accepts following values: comments, mediaquery, all.
less: {
selectors_test: {
files: {
'selectors.css': ['selectors.less']
}
}
}
As an alternative to using @import to "inline" .less files, you can specify an array of src paths and they will be concatenated.
less: {
dist: {
files: {
'test.css': ['reset.less', 'test.less']
}
}
}
You can specify multiple destination: [source] items in files.
less: {
dist: {
files: {
'test.css': ['test.less'],
'mixins.css': ['mixins.less']
}
}
}
In this example, the paths and requires options are used:
less: {
development: {
options: {
paths: ['test/fixtures'],
require: [
'globals/variables.less',
'globals/mixins.less'
]
},
files: {
'styles.css': ['styles.less']
}
},
production: {
options: {
paths: ['assets/less'],
yuicompress: true
},
files: {
'styles.min.css': ['styles.less']
}
}
}
Grunt supports filename expansion (also know as globbing) via the built-in node-glob and minimatch libraries. So Templates may be used in filepaths or glob patterns.
debug: {
options: {
paths: ['<%= tests.debug.import %>']
},
src: ['<%= tests.test.imports %>', 'test/fixtures/*.less'],
dest: 'test/result/debug'
}
For more on glob pattern syntax, see the node-glob and minimatch documentation.
Want to help make assemble-less even better? All constructive feedback and contributions are welcome, so please consider contributing! We can always use help creating, tests, documentation or resolving Issues, but if you have other ideas for how you can help, Brian and I would love to hear them!
https://github.com/assemble/assemble-less/issues
assemble-less is a powerful and flexible Grunt plugin for compiling LESS to CSS. The less task leverages JSON and Lo-dash templates for defining any number of LESS "bundles", UI components, compressed stylesheets or themes.
This Grunt.js plugin and some of the documentation on this page, is derived from grunt-contrib-less, authored by Tyler Kellen. This plugin was modified for this project to concat LESS files first, and then compile them into CSS files. This allows for prepending globally required LESS files, and it also adds the ability to build out individual CSS files, rather than building a single conctatenated file.
Jon Schlinkert
Brian Woodward
Copyright 2013 Assemble
Authored by assemble
This file was generated using Grunt and assemble on Sun Mar 24 2013 15:34:47.