less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17.02k stars 3.41k forks source link

rootpath does nothing to absolute url() paths #3552

Open gavinbarron opened 4 years ago

gavinbarron commented 4 years ago

Minimal Reproduction using less 3.12.0

fail.less:

.fail {
    background-image: url('/images/absolute.png');
}
.works {
    background-image: url('images/relative.png');
}

run:

lessc -rp=https://mycdn/url/folder fail.less ./out.css

out.css

.fail {
  background-image: url('/images/absolute.png');
}
.works {
  background-image: url('https://mycdn/url/folder/images/relative.png');
}

Why do I want this behavior? During development the images are served by the local web server in the /images directory. When publishing all static elements are served out of a folder on the CDN, the folder name is variable. This is very similar to the issue reported in #2129 but that lacked the clear detail that the image url is absolute

matthew-dean commented 3 years ago

You might need to play with rewrite-urls settings, I'm not sure: http://lesscss.org/usage/#less-options-rewrite-urls