1

Its a Rails 4 project. In the file app/assets/stylesheets/application.css.scss, I've

/*
 *= require_self
 */
@mixin row() {
  color: blue;
}

body {
  h1 {
    @include row;
  }
}

Starting the server and viewing in the browser works fine.

Now I take that mixin and put in the file vendor/assets/stylesheets/external.scss

@mixin row() {
  color: blue;
}

and require it in the application.css.scss as the following:

/*
 *= require external
 *= require_self
 */

body {
  h1 {
     @include row;
  }
}

And refresh the browser, it errors out with

Sass::SyntaxError 
Undefined mixin 'row'.

Why is the mixin defined in the external file is not working??

4

1 回答 1

0

这可能对您的错误没有太大帮助,但是从指南中可以看出:

在此示例中,使用了 require_self。这会将文件中包含的 CSS(如果有)放在 require_self 调用的精确位置。如果 require_self 被多次调用,则只考虑最后一次调用。

在这个答案中也讨论了它:require_self 是什么意思?

于 2013-10-19T15:41:51.080 回答