How to rewrite urls of images in vendor CSS files using Grunt

前端 未结 3 1874
渐次进展
渐次进展 2020-12-09 02:44

I am trying to move frontend dependencies out of the version control system. A combination of Bower.io and Grunt should be able to do this.

A problem however occurs

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 03:11

    You'll want to do some search/replace on your dist css file to generate the correct relative paths. There are a number of grunt plugins that can do this for you, personally I prefer grunt-replace. Set up your non compressed assets with variables and then produce a dist css with the URLs dynamically generated.. So:

    body {
        background:url(@@IMG_PATH/background.jpg);
    }
    

    Becomes this in dist:

    body {
        background:url(path/to/background.jpg);
    }
    

    Hope this helps.

提交回复
热议问题