我正在使用指南针,尝试在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)将不会加载到页面
答案 0 :(得分:1)
在custom.css.scss
中创建一个名为app/assets/stylesheets
的新文件,然后使用其中的所有导入
@import "foundation_and_overrides";
@import "pnp";
希望它有所帮助。
答案 1 :(得分:0)
你的问题可能是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";