Yeoman CSS图像路径

nde*_*ker 3 sass yeoman compass-sass

当我构建我的Yeoman项目时(没有什么特别的,我只使用jQuery和Modernizr),用于CSS的图像没有显示.

我的CSS代码

.contact {
    background:url(../icon-contact.png) no-repeat top center;
}
Run Code Online (Sandbox Code Playgroud)

构建应用程序后的输出(没有区别)

.contact {background:url(../icon-contact.png) no-repeat top center;}
Run Code Online (Sandbox Code Playgroud)

这不起作用,因为icon-contact.png的文件名已更改为f91724e0.icon-contact.png.

如何确保在缩小的CSS文件中更新图像路径?


编辑:我已经添加了我的解决方案作为答案

nde*_*ker 8

更新(2014年2月24日)

您可以通过添加解决这个问题<%= yeoman.dist %>/imagesassetsDirs了usemin任务.见http://www.github.com/yeoman/yeoman/issues/824#issuecomment-32691465

上一个答案(2013年3月4日)

有一个名为"usemin:css"的问题没有为 GitHub上的相关网址生成关于此特定问题的正确图像路径.Tak Tran已成为Yeoman的一个分支并实施了修复.

以下是我删除当前Yeoman安装并安装Tak Tran的分支版本的方法:

npm uninstall yeoman -g
git clone git://github.com/taktran/yeoman.git
cd yeoman/cli
npm install -g
npm link
Run Code Online (Sandbox Code Playgroud)

来源:https://github.com/yeoman/yeoman/wiki/Additional-FAQ

有了这个修复,Yeoman将重命名CSS中的相对图像路径,我的问题得到了解答.谢谢大家的帮助!