less / less.js

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

modifyvars can't resolve externals url variable #3754

Closed Zebzhong closed 1 year ago

Zebzhong commented 1 year ago

To reproduce:

const less = require("less");

let lessStr = `
@color1: 'blue';
@imgUrl: '';
@furl: 'https://qq.com';

body{
  color: @color1;
}

.myImg {
  background: url('@{imgUrl}') no-repeat;
  background-size: contain;
  width: 200px;
  height: 200px;
}

@font-face {
  font-family: 'zbtest';
  src: "url('@{furl}')";
}
.root {
  font-family: 'zbtest';
}
`

less
  .render(lessStr, {
    modifyVars: {
      color1: 'skyblue',
      imgUrl: '../test/qe.png',
      furl: "https://www.baidu.com"
    },
  })
  .then((res) => {
    console.log(res);
  });

Current behavior:

image

Expected behavior:

Can replace externals url variables correctly, Thanks

Environment information:

Zebzhong commented 1 year ago

Duplicatehttps://github.com/less/less.js/issues/2372