我试图将Bootstrap包含在我的Aurelia CLI项目中,并且CSS和JS可以正常工作。
我唯一的问题是glyphicons需要加载字体文件。
我使用以下配置:
"dependencies": [
{
"name": "bootstrap",
"path": "../node_modules/bootstrap/dist",
"main": "js/bootstrap.min",
"deps": ["jquery"],
"exports": "$",
"resources": [
"css/bootstrap.min.css",
"fonts/glyphicons-halflings-regular.woff2"
]
}
]
但是我收到包含此行的错误:
路径:'C:\ Users \ randy \ Documents \ form \ node_modules \ bootstrap \ dist \ fonts \ glyphicons-halflings-regular.js'
因此,即使我包含该.woff2
文件,Aurelia也会尝试将该文件导入为JS文件。我该怎么做才能使这项工作?CSS确实可以正常工作。
该问题已解决,有关更多信息,请阅读Github问题。
现在可以通过在aurelia.json中添加复制指令来解决此问题。
aurelia.json- 如果项目是由aurelia-cli 0.25.0或更高版本创建的,则有效
在构建块中添加以下内容:
"bundles": [ ... ],
"copyFiles": {
"node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2": "bootstrap/fonts",
"node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff": "bootstrap/fonts",
"node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf": "bootstrap/fonts"
}
如果项目是由较早的CLI版本创建的,则必须在任务文件夹中创建复制任务
之后,在build.js / ts任务中调用复制任务
*学分fabioluz的评论此GitHub上
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句