【发布时间】:2014-02-21 10:56:43
【问题描述】:
我已经使用 Yeoman 和 AngularJS(以及所有与之相关的东西,如 Grunt 和 Bower)构建了一个应用程序。
当使用grunt serve 在本地运行时,一切都可以完美运行。但是,在运行 grunt 并部署应用程序后,缺少一些资产,我不确定解决它的最佳方法是什么。
首先,运行 Grunt 似乎会将图像复制到 dist,但它会重命名它们而不调整 CSS 中的引用。 app/images/uparrow.png 变为 dist/images/3f84644a.uparrow.png。
这是 main.scss 中的一行:
.table.sortable th.sorted-asc { background-image: url(../images/uparrow.png); }
在构建过程中编译为 CSS 时,它不会重写路径,因此浏览器会尝试加载缺少的 dist/images/uparrow.png。
其次,加载 Bootstrap 插件的字体存在问题。 app/bower_components/bootstrap/dist/css/bootstrap.css 的引导 CSS 引用 ../fonts/glyphicons-halflings-regular.woff。相对路径被解析为app/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.wof,并且效果很好。
不过,一旦构建完成,供应商 CSS 就会被合并并缩小为一个位于 dist/styles/8727a602.vendor.css 的 CSS 文件。不过,字体的相对路径不会被重写。因此它会尝试在dist/fonts 文件夹中查找字体,而不是在文件实际所在的dist/bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.wof 中查找字体。
非常感谢任何建议。
【问题讨论】:
-
和我一样的问题。
grunt build没有按照应有的方式将 glyphicons 文件复制到dist文件夹。
标签: angularjs gruntjs yeoman bower