我项目中的所有 javascript 依赖项都由 bower 管理。我使用 bower-installer 过滤掉只需要的资源。其中之一是 bootstrap,其中包含一些字体,请参阅 bower 配置:
{
...
"install":{
"path":{
"js":"public/js/lib",
"map":"public/js/lib",
"css":"public/css/lib",
"less":"public/less",
"eot":"public/fonts",
"svg":"public/fonts",
"ttf":"public/fonts",
"woff":"public/fonts"
},
...
"sources":{
"bootstrap":[
".components/bootstrap/dist/js/bootstrap.min.js",
".components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot",
".components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg",
".components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf",
".components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff",
".components/bootstrap/dist/css/bootstrap.min.css"
],
}
问题是,在给定的配置下,bower 将选定的字体资源放到以下目录中:public/fonts/bootstrap/...
但是bootstrap.min.css
要求这些字体的位置如下:
@font-face {
font-family: 'Glyphicons Halflings';
src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}
这将是public/css/lib/fonts/...
,因此 404 not found 返回。有没有办法在 bower 中覆盖这些路径或在应用程序 css 中覆盖字体定义?