LESS importing CSS and relative paths

后端 未结 4 570
别跟我提以往
别跟我提以往 2021-01-03 23:25

I am using LESS to organize and import all my CSS files. I am also using Twitter Bootstrap which I integrated inside my style.less. It works fine like below however when I u

4条回答
  •  别那么骄傲
    2021-01-04 00:13

    Check out the docs for command line usage. https://github.com/cloudhead/less.js/wiki/Command-Line-Usage. There's an option called --root-path that will prepend existing urls so that they will work in the output css file.

    lessc [option option=parameter ...]  [destination]
    
    lessc -rp=will/be/prepended sourcefile.less path/to/destination
    

    For example:

    Here is the original url, with the file in css/src/nest

    background-image: url('../../../imgs/bg.png');
    

    And this is what I would do on the command line. Note that the -rp argument should point from the output directory to the original file location

    lessc -rp=src/nest css/src/nest/nesty.less css/nesty.less
    

    And the output, with the file in css/

      background-image:url('src/nest/../../../imgs/bg.png')
    

    There is a --relative-urls option, but I can't get it to work. I'm working build script that uses the workaround I described above. Build-o-Matic

    This is how I handled determining the path [link]

提交回复
热议问题