简体   繁体   English

Grunt SASS Globbing问题-导入partials文件夹时出错

[英]Grunt SASS Globbing issue - Error when importing partials folder

I am attempting to use sass globbing in my grunt project. 我正在尝试在我的grunt项目中使用sass globing。 But when I include the folder containing my partials I get the following message “Warning: Error: File to import not found or unreadable: partials” 但是,当我包含包含我的部件的文件夹时,会收到以下消息“警告:错误:找不到导入文件或文件不可读:部件”

Here is my file structure: 这是我的文件结构:

styles
|_ main.scss
|_ partials
    |_ base
        |_ _base.scss
        |_ _form.scss
        |_ _normalize.scss
    |_ layout
        |_ _constrained.scss
        |_ _footer.scss
        |_ _header.scss
        |_ _main.scss
        |_ _nav.scss
    |_ modules
        |_ _animations.scss
        |_ _btn.scss
        |_ _form-search.scss
        |_ _formatted.scss
        |_ _icons.scss
        |_ _table.scss
        |_ _video.scss
    |_ tools
        |_ _functions.scss
        |_ _helpers.scss
        |_ _mixins.scss
        |_ _site-settings.scss

Configuration in the Gruntfile.js and main.scss files: 在Gruntfile.js和main.scss文件中进行配置:

sass_globbing: {
    your_target: {
      files: {
        '_partialsMap.scss': 'partials/**/*.scss'
      },
      options: {
        useSingleQuoates: false
      }
    }
  }

in main.scss: 在main.scss中:

@import "partials/“

I suspected I had incorrectly defined my paths so tried this configuration: 我怀疑我错误地定义了路径,因此尝试了以下配置:

sass_globbing: {
    your_target: {
      files: {
        '<%= config.app %>/styles/_partialsMap.scss': '<%= config.app %>/styles/partials/**/*.scss'
      },
      options: {
        useSingleQuoates: false
      }
    }

main.scss: main.scss:

@import "partials/**/*";

and this: 和这个:

sass_globbing: {
    your_target: {
      files: {
        'styles/_partialsMap.scss': 'styles/partials/**/*.scss'
      },
      options: {
        useSingleQuoates: false
      }
    }
  }

main.scss: main.scss:

@import "partials/**/*";

I've followed the usage instructions found on the grunt-sass-globbing github page but I'm clearly doing something wrong here. 我遵循了grunt-sass-globbing github页面上的使用说明,但显然我在这里做错了。 If someone could point it out that would be great. 如果有人指出这一点,那就太好了。

Thanks 谢谢

Dave 戴夫

You should not mix the syntax from the Ruby gem sass-globbing with the syntax proposed by my plugin. 您不应将Ruby gem sass-globbing中的语法与我的插件建议的语法混合使用。

When you use the configuration below, it will create a _partialsMap.scss file. 使用以下配置时,它将创建_partialsMap.scss文件。 In your main.scss file, you have to import this newly created file with @import "partialsMap“ 在main.scss文件中,您必须使用@import "partialsMap“导入此新创建的文件

sass_globbing: {
  your_target: {
    files: {
      '_partialsMap.scss': 'partials/**/*.scss'
    },
    options: {
      useSingleQuoates: false
    }
  }
}

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

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