Ran*_*ndy 8 aurelia aurelia-cli
我正在尝试在我的Aurelia CLI项目中包含Bootstrap,并且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"
]
}
]
Run Code Online (Sandbox Code Playgroud)
但是我收到包含这一行的错误:
路径:'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"
}
Run Code Online (Sandbox Code Playgroud)
如果项目是由较旧的 CLI 版本创建的,您必须在任务文件夹中创建复制任务
之后在build.js/ts任务中调用复制任务
*感谢fabioluz在 github 上的评论
| 归档时间: |
|
| 查看次数: |
2082 次 |
| 最近记录: |