1 | # grunt-contrib-less [](https://travis-ci.org/gruntjs/grunt-contrib-less) |
---|
2 | |
---|
3 | > Compile LESS files to CSS. |
---|
4 | |
---|
5 | |
---|
6 | |
---|
7 | ## Getting Started |
---|
8 | This plugin requires Grunt `~0.4.0` |
---|
9 | |
---|
10 | If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command: |
---|
11 | |
---|
12 | ```shell |
---|
13 | npm install grunt-contrib-less --save-dev |
---|
14 | ``` |
---|
15 | |
---|
16 | Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript: |
---|
17 | |
---|
18 | ```js |
---|
19 | grunt.loadNpmTasks('grunt-contrib-less'); |
---|
20 | ``` |
---|
21 | |
---|
22 | *This plugin was designed to work with Grunt 0.4.x. If you're still using grunt v0.3.x it's strongly recommended that [you upgrade](http://gruntjs.com/upgrading-from-0.3-to-0.4), but in case you can't please use [v0.3.2](https://github.com/gruntjs/grunt-contrib-less/tree/grunt-0.3-stable).* |
---|
23 | |
---|
24 | |
---|
25 | ## Less task |
---|
26 | _Run this task with the `grunt less` command._ |
---|
27 | |
---|
28 | Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide. |
---|
29 | ### Options |
---|
30 | |
---|
31 | #### paths |
---|
32 | Type: `String|Array` |
---|
33 | Default: Directory of input file. |
---|
34 | |
---|
35 | Specifies directories to scan for @import directives when parsing. Default value is the directory of the source, which is probably what you want. |
---|
36 | |
---|
37 | #### compress |
---|
38 | Type: `Boolean` |
---|
39 | Default: False |
---|
40 | |
---|
41 | Compress output by removing some whitespaces. |
---|
42 | |
---|
43 | #### yuicompress |
---|
44 | Type: `Boolean` |
---|
45 | Default: False |
---|
46 | |
---|
47 | Compress output using cssmin.js |
---|
48 | |
---|
49 | #### ieCompat |
---|
50 | Type: `Boolean` |
---|
51 | Default: true |
---|
52 | |
---|
53 | Enforce the css output is compatible with Internet Explorer 8. |
---|
54 | |
---|
55 | For example, the [data-uri](https://github.com/cloudhead/less.js/pull/1086) function encodes a file in base64 encoding and embeds it into the generated CSS files as a data-URI. Because Internet Explorer 8 limits `data-uri`s to 32KB, the [ieCompat](https://github.com/cloudhead/less.js/pull/1190) option prevents `less` from exceeding this. |
---|
56 | |
---|
57 | #### optimization |
---|
58 | Type: `Integer` |
---|
59 | Default: null |
---|
60 | |
---|
61 | 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. |
---|
62 | |
---|
63 | #### strictImports |
---|
64 | Type: `Boolean` |
---|
65 | Default: False |
---|
66 | |
---|
67 | Force evaluation of imports. |
---|
68 | |
---|
69 | #### syncImport |
---|
70 | Type: `Boolean` |
---|
71 | Default: False |
---|
72 | |
---|
73 | Read @import'ed files synchronously from disk. |
---|
74 | |
---|
75 | #### dumpLineNumbers |
---|
76 | Type: `String` |
---|
77 | Default: false |
---|
78 | |
---|
79 | Configures -sass-debug-info support. |
---|
80 | |
---|
81 | Accepts following values: `comments`, `mediaquery`, `all`. |
---|
82 | |
---|
83 | #### relativeUrls |
---|
84 | Type: `boolean` |
---|
85 | Default: false |
---|
86 | |
---|
87 | Rewrite urls to be relative. False: do not modify urls. |
---|
88 | |
---|
89 | #### report |
---|
90 | Choices: `false` `'min'` `'gzip'` |
---|
91 | Default: `false` |
---|
92 | |
---|
93 | Either do not report anything, report only minification result, or report minification and gzip results. This is useful to see exactly how well Less is performing, but using `'gzip'` can add 5-10x runtime task execution. |
---|
94 | |
---|
95 | Example ouput using `'gzip'`: |
---|
96 | |
---|
97 | ``` |
---|
98 | Original: 198444 bytes. |
---|
99 | Minified: 101615 bytes. |
---|
100 | Gzipped: 20084 bytes. |
---|
101 | ``` |
---|
102 | |
---|
103 | ### Usage Examples |
---|
104 | |
---|
105 | ```js |
---|
106 | less: { |
---|
107 | development: { |
---|
108 | options: { |
---|
109 | paths: ["assets/css"] |
---|
110 | }, |
---|
111 | files: { |
---|
112 | "path/to/result.css": "path/to/source.less" |
---|
113 | } |
---|
114 | }, |
---|
115 | production: { |
---|
116 | options: { |
---|
117 | paths: ["assets/css"], |
---|
118 | yuicompress: true |
---|
119 | }, |
---|
120 | files: { |
---|
121 | "path/to/result.css": "path/to/source.less" |
---|
122 | } |
---|
123 | } |
---|
124 | } |
---|
125 | ``` |
---|
126 | |
---|
127 | ## Release History |
---|
128 | |
---|
129 | * 2013-08-08âââv0.6.5âââSupport strictMath option Support rootpath parse option |
---|
130 | * 2013-07-09âââv0.6.4âââSupport relativeUrls option |
---|
131 | * 2013-07-06âââv0.6.3âââAdd report option for minification and gzip results |
---|
132 | * 2013-07-03âââv0.6.2âââsupport syncImport |
---|
133 | * 2013-06-12âââv0.6.1âââSupport ieCompat |
---|
134 | * 2013-06-09âââv0.6.0âââBump less to 1.4.0 |
---|
135 | * 2013-05-23âââv0.5.2âââImprove error handling. |
---|
136 | * 2013-04-25âââv0.5.1âââGracefully handle configuration without sources. |
---|
137 | * 2013-02-15âââv0.5.0âââFirst official release for Grunt 0.4.0. |
---|
138 | * 2013-01-23âââv0.5.0rc7âââUpdating grunt/gruntplugin dependencies to rc7. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions. Remove experimental wildcard destination support. Switching to this.files api. |
---|
139 | * 2012-10-18âââv0.3.2âââAdd support for dumpLineNumbers. |
---|
140 | * 2012-10-12âââv0.3.1âââRename grunt-contrib-lib dep to grunt-lib-contrib. |
---|
141 | * 2012-09-24âââv0.3.0âââGlobal options depreciated Revert normalize linefeeds. |
---|
142 | * 2012-09-16âââv0.2.2âââSupport all less options Normalize linefeeds Default path to dirname of src file. |
---|
143 | * 2012-09-10âââv0.2.0âââRefactored from grunt-contrib into individual repo. |
---|
144 | |
---|
145 | --- |
---|
146 | |
---|
147 | Task submitted by [Tyler Kellen](http://goingslowly.com/) |
---|
148 | |
---|
149 | *This file was generated on Thu Aug 08 2013 09:12:41.* |
---|