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/less-options.md
+44-15
Original file line number
Diff line number
Diff line change
@@ -22,41 +22,70 @@ Allows you to add a path to every generated import and url in your css. This doe
22
22
23
23
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.
By default URLs are kept as-is, so if you import a file in a sub-directory that references an image, exactly the same URL will be output in the css. This option allows you to re-write URL's in imported files so that the URL is always relative to the base imported file. E.g.
33
+
By default URLs are kept as-is (`off`), so if you import a file in a sub-directory that references an image, exactly the same URL will be output in the css. This option allows you to rewrite URLs in imported files so that the URL is always relative to the base file that has been passed to Less. E.g.
32
34
33
-
```less
34
-
# main.less
35
-
@import"files/backgrounds.less";
36
-
# files/backgrounds.less
37
-
.icon-1 {
38
-
background-image: url('images/lamp-post.png');
35
+
```css
36
+
/* main.less */
37
+
@import"global/fonts.less";
38
+
```
39
+
40
+
```css
41
+
/* global/fonts.less */
42
+
@font-face {
43
+
font-family: 'MyFont';
44
+
src: url('myfont/myfont.woff2') format('woff2');
39
45
}
40
46
```
41
47
42
-
this will output the following normally
48
+
With nothing set or with `rewriteUrls: 'off'`, compiling `main.less` will output:
43
49
44
50
```css
45
-
.icon-1 {
46
-
background-image: url('images/lamp-post.png');
51
+
/* main.less */
52
+
/* global/fonts.less */
53
+
@font-face {
54
+
font-family: 'MyFont';
55
+
src: url('myfont/myfont.woff2') format('woff2');
47
56
}
48
57
```
49
58
50
-
but with `relativeUrls: true`, it will instead output
This can be useful in case you're combining Less with [CSS Modules](https://github.com/css-modules/css-modules) which use similar resolving semantics like Node.js.
78
+
58
79
You may also want to consider using the data-uri function instead of this option, which will embed images into the css.
0 commit comments