【问题标题】:rails error compiling css assetrails错误编译css资产
【发布时间】:2013-10-07 20:34:03
【问题描述】:

我正在使用指南针,尝试在 application.scss 中导入我的自定义 scss 文件并出现此错误:

这里是我的 application.scss 代码:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the top of the
 * compiled file, but it's generally better to create a new file per style scope.
 *
 *= require_self
 *= require_tree
 */

@import "foundation_and_overrides";
@import "pnp";

如果我删除 require_tree 错误消息将消失,但我的 scss 文件 (pnp.scss) 不会加载到页面

【问题讨论】:

  • button mixin 在哪里?您的 pnp 文件似乎正在尝试使用它,但找不到它。

标签: css ruby-on-rails sass compass-sass


【解决方案1】:

app/assets/stylesheets 中创建一个名为custom.css.scss 的新文件,然后使用那里的所有导入

@import "foundation_and_overrides";
@import "pnp";

希望对你有帮助。

【讨论】:

    【解决方案2】:

    你的问题可能是 require_self 发生在 require_tree 之前。这意味着pnp 样式将无法访问可能在其之后加载的任何其他样式表(即,包含混入)。

    为了避免这种混淆,我通常将所有导入保存在一个 SCSS 文件中,并且只需要在 application.css 中。

    # application.css
    
    /*
     *= require normalize
     *= require base
    */
    
    
    # base.scss
    
    @import "foundation_and_overrides";
    @import "constants";
    @import "buttons";
    @import "pnp";
    

    【讨论】:

      猜你喜欢
      • 2016-10-14
      • 1970-01-01
      • 1970-01-01
      • 2017-04-17
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多