简体   繁体   English

sss和引导问题与导入scss文件

[英]sass and bootstrap issue with importing scss file

M using sass with bootstrap 4 n now what i do here is sass folder i have app.scss file wherein i have M将sass与bootstrap 4 n一起使用现在我在这里做的是sass文件夹,我有app.scss文件,其中

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

when i compile the sass file i get the following error 当我编译sass文件时,出现以下错误

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

as m newbie to sass y is it not importing the files 作为新手萨斯是不是导入文件

it works for the following only when i have the entire bootstrap it comiples 它仅在我拥有整个引导程序时才适用于以下内容

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

any help would be appreciated 任何帮助,将不胜感激

Since you are using scss you should use string for the import value and omit the underscore: 由于使用的是scss ,因此应使用字符串作为导入值,并省略下划线:

@import 'customVariables.scss';

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

Let's say you have a couple of Sass files, _reset.scss, and base.scss. 假设您有几个Sass文件,_reset.scss和base.scss。 We want to import _reset.scss into base.scss. 我们想将_reset.scss导入base.scss。

@import 'reset';


EDIT : Provide a working example so the OP is able to see all dependent parts working together. 编辑 :提供一个有效的示例,以便OP能够看到所有相关的部分一起工作。

I've created a project on codesandbox, where I've added sass and bootstrap and used the guide on bootstrap to theme the build: 我在codesandbox上创建了一个项目,在其中添加了sassbootstrap并使用了bootstrap上的指南对构建进行主题化:

https://codesandbox.io/s/v0k9wlwqx3 https://codesandbox.io/s/v0k9wlwqx3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM