简体   繁体   English

Gulp Sass-控制台无错误

[英]Gulp Sass - no errors to console

I have the following code in my glup.js file 我的glup.js文件中包含以下代码

var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');

gulp.task('default', function() {
    gulp.src('./stylesheets/*.{scss,sass}')
    .pipe(sourcemaps.init())
    .pipe(sass().on('error', sass.logError))
    .pipe(sourcemaps.write())
    .pipe(gulp.dest('./css'));
});

gulp.task('default',function() {
    gulp.watch('sass/**/*.scss',['default']);
});

If I have valid sass in my style.scss file it correctly generates the style.css and style.css.map files, however, if errors are in the style.scss file no output is propogating to the console. 如果我的style.scss文件中包含有效的sass,它将正确生成style.css和style.css.map文件,但是,如果style.scss文件中存在错误,则不会向控制台传播任何输出。

Does anyone have any ideas as to why? 有人对为什么有任何想法吗?

You have two tasks named default . 您有两个名为default任务。 Name the first sass and change your watch task to execute the sass command. 命名第一个sass并更改您的监视任务以执行sass命令。

Also, my error logging looks like this, with and extra .sync() method call: 另外,我的错误记录如下所示,并带有额外的.sync()方法调用:

.pipe(sass.sync().on('error', sass.logError))

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

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