【问题标题】:sass and bootstrap issue with importing scss file导入 scss 文件的 sass 和引导问题
【发布时间】:2019-03-16 09:32:55
【问题描述】:

M 使用 sass 和 bootstrap 4 n 现在我在这里做的是 sass 文件夹,我有 app.scss 文件,其中有

@import _customVariables.scss
@import node_modules/bootstrap/scss/functions
@import node_modules/bootstrap/scss/mixins

当我编译 sass 文件时出现以下错误

sass --watch app.scss:style.css
 Error: Expected string.
 @import _customVariables.scss
         ^
 app.scss 1:9  root stylesheet

作为新手到 sass y 是不是不导入文件

仅当我拥有它编译的整个引导程序时,它才适用于以下情况

  @import "../node_modules/bootstrap/scss/bootstrap"

任何帮助将不胜感激

【问题讨论】:

    标签: css sass bootstrap-4


    【解决方案1】:

    由于您使用的是scss,因此您应该使用字符串作为导入值并省略下划线:

    @import 'customVariables.scss';
    

    根据 SASS 文档 (https://sass-lang.com/guide#import):

    假设您有几个 Sass 文件,_reset.scss 和 base.scss。我们想将 _reset.scss 导入到 base.scss 中。

    @import 'reset';


    编辑:提供一个工作示例,以便 OP 能够看到所有相关部分一起工作。

    我在代码沙箱上创建了一个项目,在其中添加了 sassbootstrap 并使用引导程序上的指南为构建主题:

    https://codesandbox.io/s/v0k9wlwqx3

    【讨论】:

    • 这还没有解决。它仅在我拥有整个引导程序 @import "../node_modules/bootstrap/scss/bootstrap" 但没有任何自定义文件时才有效
    • 没有更多信息很难获得任何帮助,您现在遇到的错误是什么?
    • 添加了一个示例,这样您就可以看到一个完整的示例,并且只从引导程序中导入最小的组件集。
    猜你喜欢
    • 2016-01-25
    • 2019-05-18
    • 2016-12-12
    • 2017-04-24
    • 2022-08-10
    • 2018-12-18
    • 2019-05-05
    • 2014-03-26
    • 1970-01-01
    相关资源
    最近更新 更多