在 Express 中包括 Bootstrap 个字形

Including Bootstrap Glyphicons In Express

我正在尝试在我的 Express 应用程序中使用字形图标(通过 bootstrap)。问题是当我提供我的静态文件时,不包括字形。

这是我的目录(由 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 的错误:

users:1 GET http://localhost:3000/fonts/glyphicons-halflings-regular.woff 404 (Not Found) users:1 GET http://localhost:3000/fonts/glyphicons-halflings-regular.ttf 404 (Not Found)

我试过切换到

app.use('/build/', express.static(path.join(__dirname, 'build/fonts')));

但我很确定 bootstrap 正在寻找 ../fonts,所以目录不可能完全相同。换句话说,bootstrap 需要这样的结构:

js/bootstrap.js
fonts/glyphs

我去哪儿了?

谢谢大家!

然后使用以下内容:

app.use('/fonts/', express.static(path.join(__dirname, 'build/fonts')));