简体   繁体   English

Gulp没有正确地看我的scss文件

[英]Gulp not watching my scss file correctly

I've seen plenty of stackoverflow solutions to this, but none of the appear to work in my scenario. 我已经看到了大量的stackoverflow解决方案,但似乎没有一个在我的场景中起作用。

My gulp watch appears to be watching the file but the output file is not being updated. 我的gulp手表似乎正在观看文件,但输出文件没有更新。

Running gulp works okay as it default is set to call the sass task, and the task successfully compiles my output css. 运行gulp工作正常,因为默认设置为调用sass任务,任务成功编译我的输出css。

Here is my directory structure: 这是我的目录结构:

- css  
  - sass  
    * style.scss     
  * style.css  
* gulpfile.js

and my gulpfile: 和我的gulpfile:

// include gulp
var gulp = require('gulp');

// include plugins
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var cssbeautify = require('gulp-cssbeautify');
var cssmin = require('gulp-cssmin');

// compile sass
gulp.task('sass', function  () {
    return gulp.src('./css/sass/*.scss')
        .pipe(sass())
        .pipe(cssbeautify())
        .pipe(gulp.dest('css'));
});

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

// default task
gulp.task('default', ['sass']);

gulp watch gives me: (11:01 is when I saved the file) gulp watch给了我:(11:01是我保存文件的时候)

[10:59:48] Using gulpfile ~/Sites/cla/8_0/web/intranet/reports/gulpfile.js [10:59:48]使用gulpfile~ / Sites / cla / 8_0 / web / intranet / reports / gulpfile.js
[10:59:48] Starting 'watch'... [10:59:48]开始'看'...
[10:59:48] Finished 'watch' after 12 ms [10:59:48] 12毫秒后完成'观看'
[11:01:25] Starting 'sass'... [11:01:25]开始'sass'......
[11:01:25] Finished 'sass' after 24 ms [11:01:25] 24毫秒后完成'sass'

Any ideas as to why my output css isn't changing? 关于为什么我的输出css没有改变的任何想法?

Many thanks! 非常感谢!

It could be an sass synthax error issue, since you dont have any functionality in your sass taks no handle then. 它可能是一个sass synthax错误问题,因为你没有任何功能在你的sass taks没有句柄然后。

Here is an example from my gulpfile 这是我的gulpfile的一个例子

Try to add .on('error', sass.logError)), after your .pipe(sass()), here is a rough example: 尝试添加.on('error',sass.logError)),在.pipe(sass())之后,这是一个粗略的例子:

gulp.task('sass',function(){                 
  gulp.src('./src/sass/main.scss')  
    .pipe(sass().on('error', sass.logError))
});

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

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