You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/usage/command-line-usage.md
+54-46Lines changed: 54 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,9 @@ Note that a [tilde version range][] will be automatically specified in `package.
30
30
31
31
#### Beta releases of lessc
32
32
33
-
Periodically, as new functionality is being developed, lessc builds will be published to npm, tagged as. These builds will _not_ be published as a `@latest` official release, and will typically have a build number or alpha/beta/release candidate designation.
33
+
Periodically, as new functionality is being developed, lessc builds will be published to npm, tagged as beta. These builds will _not_ be published as a `@latest` official release, and will typically have beta in the version (use `lessc -v` to get current version).
34
34
35
-
Since patch releases are non-breaking we will publish patch releases immediately and alpha/beta/candidate versions will be published as minor or major version upgrades (we endevour since 1.4.0 to follow [semantic versioning](http://semver.org/)).
35
+
Since patch releases are non-breaking we will publish patch releases immediately and alpha/beta/candidate versions will be published as minor or major version upgrades (we endeavour since 1.4.0 to follow [semantic versioning](http://semver.org/)).
36
36
37
37
#### Installing an unpublished development version of lessc
Prints a help message with available options and exits.
79
81
80
-
### Include paths
82
+
####Include paths
81
83
82
84
```bash
83
85
lessc --include-path=PATH1;PATH2
@@ -92,34 +94,34 @@ In node, set a paths option
92
94
{ paths: ['PATH1', 'PATH2'] }
93
95
```
94
96
95
-
### Makefile
97
+
####Makefile
96
98
97
99
```bash
98
100
lessc -M
99
101
lessc --depends
100
102
```
101
103
102
-
### No Color
104
+
####No Color
103
105
104
106
```bash
105
107
lessc --no-color
106
108
```
107
109
108
-
### No IE Compatability
110
+
####No IE Compatability
109
111
110
112
```bash
111
113
lessc --no-ie-compat
112
114
```
113
115
114
116
Currently only used for the data-uri function to ensure that images aren't created that are too large for the browser to handle.
115
117
116
-
### Disable JavaScript
118
+
####Disable JavaScript
117
119
118
120
```bash
119
121
lessc --no-js
120
122
```
121
123
122
-
### Lint
124
+
####Lint
123
125
124
126
```bash
125
127
lessc --lint
@@ -128,33 +130,35 @@ lessc --l
128
130
129
131
Runs the less parser and just reports errors without any output.
130
132
131
-
### Silent
133
+
####Silent
132
134
133
135
```bash
134
136
lessc -s
135
137
lessc --silent
136
138
```
137
139
138
-
### Strict Imports
140
+
Stops any warnings from being shown.
141
+
142
+
#### Strict Imports
139
143
140
144
```bash
141
145
lessc --strict-imports
142
146
```
143
147
144
-
### Allow imports from insecure https hosts
148
+
####Allow imports from insecure https hosts
145
149
146
150
```bash
147
151
lessc --insecure
148
152
```
149
153
150
-
### Version
154
+
####Version
151
155
152
156
```bash
153
157
lessc -v
154
158
lessc --version
155
159
```
156
160
157
-
### Compress
161
+
####Compress
158
162
159
163
```bash
160
164
lessc -x
@@ -163,25 +167,11 @@ lessc --compress
163
167
164
168
Compress using less built-in compression. This does an okay job but does not utilise all the tricks of dedicated css compression. Please feel free to improve our compressed output with a pull request.
165
169
166
-
### Clean CSS
167
-
168
-
```bash
169
-
lessc --clean-css
170
-
```
171
-
172
-
Clean CSS is our minifer of choice if you want to get the most minified you can. This option switches it on.
173
-
174
-
Note - it does not yet support sourcemaps, for that you can only use our own compression.
Use this to pass options to clean css. The default options are the safest, so are IE8 compatible.
172
+
In v2 of less, Clean CSS is no longer included as a direct dependency. To use clean css with lessc, use the [clean css plugin](https://github.com/less/less-plugin-clean-css).
183
173
184
-
### Source Map Output Filename
174
+
####Source Map Output Filename
185
175
186
176
```bash
187
177
lessc --source-map
@@ -190,14 +180,16 @@ lessc --source-map=file.map
190
180
191
181
Tells less to generate a sourcemap. If you have the sourcemap option without a filename it will use the source less file name but with the extension map.
192
182
193
-
### Source Map Rootpath
183
+
####Source Map Rootpath
194
184
195
185
```bash
196
186
lessc --source-map-rootpath=dev-files/
197
187
```
198
188
199
189
Specifies a rootpath that should be prepended to each of the less file paths inside the sourcemap and also to the path to the map file specified in your output css.
200
190
191
+
Because the basepath defaults to the directory of the input less file, the rootpath defaults to the path from the sourcemap output file to the base directory of the input less file.
192
+
201
193
Use this option if for instance you have a css file generated in the root on your web server but have your source less/css/map files in a different folder. So for the option above you might have
202
194
203
195
```bash
@@ -206,15 +198,17 @@ dev-files/output.map
206
198
dev-files/main.less
207
199
```
208
200
209
-
### Source Map Basepath
201
+
####Source Map Basepath
210
202
211
203
```bash
212
204
lessc --source-map-basepath=less-files/
213
205
```
214
206
215
-
This is the opposite of the rootpath option, it specifies a path which should be removed from the output paths. For instance if you are compiling a file in the less-files directory but the source files will be available on your web server in the root or current directory, you can specify this to remove the additional `less-files` part of the path
207
+
This is the opposite of the rootpath option, it specifies a path which should be removed from the output paths. For instance if you are compiling a file in the less-files directory but the source files will be available on your web server in the root or current directory, you can specify this to remove the additional `less-files` part of the path.
216
208
217
-
### Source Map Less Inline
209
+
It defaults to the path to the input less file.
210
+
211
+
#### Source Map Less Inline
218
212
219
213
```bash
220
214
lessc --source-map-less-inline
@@ -224,23 +218,23 @@ This option specifies that we should include all of the Less files in to the sou
224
218
225
219
This can be used in conjunction with the map inline option so that you do not need to have any additional external files at all.
226
220
227
-
### Source Map Map Inline
221
+
####Source Map Map Inline
228
222
229
223
```bash
230
224
lessc --source-map-map-inline
231
225
```
232
226
233
227
This option specifies that the map file should be inline in the output CSS. This is not recommended for production, but for development it allows the compiler to produce a single output file which in browsers that support it, use the compiled css but show you the non-compiled less source.
234
228
235
-
### Source Map URL
229
+
####Source Map URL
236
230
237
231
```bash
238
232
lessc --source-map-url=../my-map.json
239
233
```
240
234
241
235
Allows you to override the URL in the css that points at the map file. This is for cases when the rootpath and basepath options are not producing exactly what you need.
242
236
243
-
### Rootpath
237
+
####Rootpath
244
238
245
239
```bash
246
240
lessc -rp=resources/
@@ -251,7 +245,7 @@ Allows you to add a path to every generated import and url in your css. This doe
251
245
252
246
For instance, if all the images the css use are in a folder called resources, you can use this option to add this on to the URL's and then have the name of that folder configurable.
253
247
254
-
### Relative URLs
248
+
####Relative URLs
255
249
256
250
```bash
257
251
lessc -ru
@@ -287,14 +281,14 @@ but with this option on it will instead output
287
281
288
282
You may also want to consider using the data-uri function instead of this option, which will embed images into the css.
289
283
290
-
### Strict Math
284
+
####Strict Math
291
285
292
286
```bash
293
287
lessc -sm=on
294
288
lessc --strict-math=on
295
289
```
296
290
297
-
Defaults to Off.
291
+
Defaults to Off.
298
292
299
293
Without this option on Less will try and process all maths in your css e.g.
300
294
@@ -326,7 +320,7 @@ With strict math on, only maths that is inside un-necessary parenthesis will be
326
320
327
321
We originally planned to default this to true in the future, but it has been a contraversial option and we are considering whether we have solved the problem in the right way, or whether less should just have exceptions for instances where `/` is valid or calc is used.
328
322
329
-
### Strict Units
323
+
####Strict Units
330
324
331
325
```bash
332
326
lessc -su=on
@@ -347,31 +341,31 @@ In this case, things are clearly not right - a length multiplied by a length giv
347
341
348
342
With strict units on, we assume this is a bug in the calculation and throw an error.
349
343
350
-
### Global Variable
344
+
####Global Variable
351
345
352
346
```bash
353
347
lessc --global-var="my-background=red"
354
348
```
355
349
356
350
This option defines a variable that can be referenced by the file. Effectively the declaration is put at the top of your base Less file, meaning it can be used but it also can be overridden if this variable is defined in the file.
357
351
358
-
### Modify Variable
352
+
####Modify Variable
359
353
360
354
```bash
361
355
lessc --modify-var="my-background=red"
362
356
```
363
357
364
358
As opposed to the global variable option, this puts the declaration at the end of your base file, meaning it will override anything defined in your Less file.
365
359
366
-
### URL Arguments
360
+
####URL Arguments
367
361
368
362
```bash
369
363
lessc --url-args="cache726357"
370
364
```
371
365
372
366
This option allows you to specify a argument to go on to every URL. This may be used for cache-busting for instance.
373
367
374
-
### Line Numbers
368
+
####Line Numbers
375
369
376
370
```bash
377
371
lessc --line-numbers=comments
@@ -380,3 +374,17 @@ lessc --line-numbers=all
380
374
```
381
375
382
376
Generates inline source-mapping. This was the only option before browsers started supporting sourcemaps. We are consider deprecating, so please get in touch if you want this option to stick around.
377
+
378
+
#### Plugin
379
+
380
+
```bash
381
+
lessc --clean-css
382
+
lessc --plugin=clean-css="advanced"
383
+
```
384
+
385
+
--plugin Loads a plugin. You can also omit the --plugin= if the plugin begins
386
+
less-plugin. E.g. the clean css plugin is called less-plugin-clean-css
387
+
once installed (npm install less-plugin-clean-css), use either with
388
+
--plugin=less-plugin-clean-css or just --clean-css
389
+
specify options afterwards e.g. --plugin=less-plugin-clean-css="advanced"
Copy file name to clipboardExpand all lines: content/usage/developing-less.md
+19-1Lines changed: 19 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -31,9 +31,27 @@ Other grunt commands
31
31
*`grunt stable` to create a new release
32
32
*`grunt readme` to generate a new readme.md in the root directory (after each release)
33
33
34
+
## How to run less in other environments
35
+
36
+
If you look in the libs folder you will see `less`, `less-node`, `less-browser`. The less folder is pure javascript with no environment
37
+
specifics. if you require `less/libs/less`, you get a function that takes an environment object and an array of file managers. The file
38
+
managers are the same file managers that can also be written as a plugin.
39
+
40
+
```js
41
+
var createLess =require("less/libs/less"),
42
+
myLess =createLess(environment, [myFileManager]);
43
+
```
44
+
45
+
The environment api is specified in [less/libs/less/environment/environment-api.js](https://github.com/less/less.js/blob/master/lib/less/environment/environment-api.js)
46
+
and the file manager api is specified in [less/libs/less/environment/file-manager-api.js](https://github.com/less/less.js/blob/master/lib/less/environment/file-manager-api.js).
47
+
48
+
For file managers we highly recommend setting the prototype as a new AbstractFileManager - this allows you to override what is needed and allows us
49
+
to implement new functions without breaking existing file managers. For an example of file managers, see the 2 node implementations, the browser implementation or
50
+
the npm import plugin implementation.
51
+
34
52
## Guide
35
53
36
-
If you look at [http://www.gliffy.com/go/publish/4784259](http://www.gliffy.com/go/publish/4784259), This is an overview diagram of how less works.
54
+
If you look at [http://www.gliffy.com/go/publish/4784259](http://www.gliffy.com/go/publish/4784259), This is an overview diagram of how less works. Warning! It needs updating with v2 changes.
0 commit comments