【问题标题】:Including external css files in Famo.us project在 Famo.us 项目中包含外部 css 文件
【发布时间】:2014-04-13 18:39:51
【问题描述】:

我使用 Famo.us 的 Yeoman 生成器创建了一个项目。它创建一个 index.html 文件、一个样式文件夹、一个 src 文件夹和一个内容文件夹。 gruntfile 指定 index.html 包含样式文件夹下的所有 css 文件。但是,我想通过在我的 index.html 中引用它来包含一个 google 字体 css 文件。我无法手动插入它,因为每次我在项目中保存文件时 grunt 都会覆盖我的更改,我该如何让 grunt 加载我的外部 css 文件/在我的 index.html 文件中引用它们?

【问题讨论】:

    标签: javascript gruntjs famo.us


    【解决方案1】:

    确保将样式表包含在<!-- build:css cmets 之外。

    这行得通:

    <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 -->
    

    疑难解答:

    • 如果这不适用于实时重新加载,请尝试重新启动服务器!
    • 务必刷新页面(即清除缓存或打开开发者控制台)

    示例文件:

    见example files in this gist!

    说明:

    在 index.html 中重写 CSS 样式表的特定 Grunt 任务称为 cssmin,它与 useminPrepare 和 usemin 结合使用。

    基本上,useminPrepare 会根据您的 html 文件中的 &lt;!-- build:css cmets 为您编写一个 cssmin 配置。请参阅usemin docs。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-19
      • 2014-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-29
      • 2018-01-17
      • 1970-01-01
      相关资源
      最近更新 更多