我正在尝试在Express应用中使用glyphicons(通过引导程序)。问题是当我提供静态文件时,不包括字形图标。
这是我的目录(由grunt创建):
Build
fonts
glyphicons-halflings.eot
...
js
scripts.js
stylesheets
styles.css
这是我的app.js代码:
app.use('/build/', express.static(path.join(__dirname, 'build/js')));
app.use('/build/', express.static(path.join(__dirname, 'build/stylesheets')));
app.use(express.static(path.join(__dirname, 'build/fonts')));
这是chrome产生的错误:
用户:1 GET
http://localhost:3000/fonts/glyphicons-halflings-regular.woff 404(不是
找到)个用户:1 GET
http://localhost:3000/fonts/glyphicons-halflings-regular.ttf 404(不是
找到)
我尝试切换到
app.use('/build/', express.static(path.join(__dirname, 'build/fonts')));
但是我很确定bootstrap正在寻找../fonts,所以目录不可能完全一样。换句话说,引导程序期望这样的结构:
js/bootstrap.js
fonts/glyphs
我要去哪里?
感谢大家!
最佳答案
只需使用以下内容即可:
app.use('/fonts/', express.static(path.join(__dirname, 'build/fonts')));