我使用 Famo.us 的 Yeoman 生成器创建了一个项目。它创建一个 index.html 文件、一个样式文件夹、一个 src 文件夹和一个内容文件夹。gruntfile 指定 index.html 包含样式文件夹下的所有 css 文件。但是,我想通过在我的 index.html 中引用它来包含一个 google 字体 css 文件。我无法手动插入它,因为每次我在项目中保存文件时 grunt 都会覆盖我的更改,我该如何让 grunt 加载我的外部 css 文件/在我的 index.html 文件中引用它们?
问问题
387 次
1 回答
3
确保在注释之外包含您的样式表。<!-- build:css
这有效:
<link href='http://fonts.googleapis.com/css?family=Gochi+Hand' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="lib/famous/core/famous.css" />
<!-- build:css(app/) css/app.css -->
<link rel="stylesheet" type="text/css" href="styles/app.css" />
<!-- bower:css -->
故障排除:
- 如果这不适用于实时重新加载,请尝试重新启动服务器!
- 一定要刷新页面(即清除缓存或打开开发者控制台)
示例文件:
请参阅此要点中的示例文件!
解释:
在 index.html 中重写 CSS 样式表的特定 Grunt 任务称为cssmin
,它与useminPrepare
和结合使用usemin
。
基本上,根据您的 html 文件中的注释为您useminPrepare
编写配置。请参阅usemin文档。cssmin
<!-- build:css
于 2014-04-13T10:34:42.187 回答