Closed otakustay closed 10 years ago
我用node编译试了下,路径正常。你是不是指定了--relative-urls
参数。这会修改url地址
嗯,没错的话edp-build
是默认有这参数的,为了一堆less合在一起@import
到一具main.less
的时候图片地址还是正确的……结果mixin
就会被坑到
补一下:https://github.com/ecomfe/edp-build/blob/master/lib/processor/less-compiler.js#L58
对于这个问题,我在想less是不是支持搞成这样:
.my-class { .img-replace(url(../img/abc.png)); }
这样会不会跟着我自己的less文件走?如果会的话是不是能加上.img-replace-naked
之类的
似乎所有用到 url()
的地方都有这个问题耶。
是啊,基本上全有这问题,我们这边的.linear-gradient-with-background-image
也是这问题,不知道有没有只求办法绕过去解决的?我想把多个less给@import
到一起是个比较常见的手段,因此--relative-urls
开头也经常是开着的,这种情况下mixin的实用价值很惨
@otakustay 有一个方法是把 mixin 里面输出 url 的部分全部替换成 ~"url(@{img-url})"
,这样就是你写啥我输出啥。
根据 https://github.com/ecomfe/est/blob/master/src/typography.less#L124 ,
img-replace
默认使用了url()
格式,所以我现在有这样的情况:最后编译后,会变成相对于est所在目录的地址,而不是定义
.my-class
的css所在目录为基准不太懂less,可能是由于编译时用了啥参数还是因为加了冒号导致的,正确的用法应该是啥?