2016-08-17 114 views
0

我试图编译我的SCSS,而且我有一个相当莫名的吞咽错误。未定义的scss变量错误

enter image description here

所以我检查了我的代码,一切显示正常。这是我的_colors.scss文件中的变量。

// dark shades 
$gray1:   #3c3c3d !default; 
$gray2:   #5a5a5b !default; 
$gray3:   #7d7d7e !default; 

这里还有被触发错误_base.scss

body{ 
    box-sizing: border-box; 
    color: $gray1; 
    font-family: $base-font; 
    font-size: $font-size; 
    line-height: $line-height; 
    min-height: 100%; 
    position: relative; 
} 

线路,这里是我的gulpfile CSS的任务,我跑了。

gulp.task('css', function() { 
    return sass('scss/**/*.scss') 
     .pipe(sourcemaps.init()) 
     .pipe(autoprefixer()) 
     .pipe(concat('styles.css')) 
     .on('error', sass.logError) 
     .pipe(sourcemaps.write()) 
     .pipe(gulp.dest('./css')) 
      .pipe(notify({ message: 'Wait for it....wait for it!!!' })); 
}); 

我所有的代码也是this repository如果你想闲逛(它没有太多尚)

+0

你是否在_base.scss之前包含_collors.scss,如果不是它可能是它编译它时,它不会知道变量,因为它在以后得到重点 –

+0

啊!而已。自从我使用SASS以来已经有一段时间了。添加您的评论作为答案,我会标记它是正确的。 –

回答

1

你包括_base.scss前_collors.scss如果没有则可能是当它编译它时,它不知道变量,因为它在稍后得到重入点