Error No such file or directory during Gulp-Ruby-Sass Task

[亡魂溺海] 提交于 2019-12-25 04:26:50

问题


I'm using Gulp as my task runner, and gulp-ruby-sass to compile my sass files into css.

The error I'm getting on my gulp default task:

My default Gulp task:

gulp.task('default', ['delete', 'web_css', 'dash_css', 'web_js', 'dash_js']);

My 2 compile SASS tasks:

// Compile public SASS
gulp.task('web_css', function() {
    return sass('client/website/_sources/sass/bitage_web.scss', { style: 'compressed' })
        .pipe(sourcemaps.init())
        .pipe(sourcemaps.write('./maps'))
        .pipe(gulp.dest('client/website/assets/css'));
});

// Compile dashboard SASS
gulp.task('dash_css', function() {
    return sass('client/dashboard/_sources/sass/bitage_app.scss', { style: 'compressed' })
        .pipe(sourcemaps.init())
        .pipe(sourcemaps.write('./maps'))
        .pipe(gulp.dest('client/dashboard/assets/css'));
});

Both tasks above are virtually identically.

When I run the default task (gulp):

  1. The website css compiles ok
  2. All the js compiles ok
  3. But then I get that error before the dash_css finishes, and the css is not compiled :(

Additional notes:

  • If make a change in gulp watch the dash_css will compile just fine.
  • If I run just gulp dash_css it also compiles just fine.
  • I only have this Errno::ENOENT bug when I run the default task.

Do you see anything strange above? Or have run into this issue before?


回答1:


Use callback so that gulp knows when the task is complete:

gulp.task('delete', function(cb) {
    del([
        'client/website/assets/css/maps',
        'client/website/assets/css/bitage_web.css',
        'client/dashboard/assets/css/maps',
        'client/dashboard/assets/css/bitage_app.css',
        'client/website/assets/js/*',
        'client/dashboard/assets/js/*'
    ], cb);
});

Make delete run before other tasks for example with run-sequence.




回答2:


I've changed

gulp.task('web_css', function() {
    return sass(....

to:

gulp.task('web_css', function() {
    return gulp.src('


来源:https://stackoverflow.com/questions/28686605/error-no-such-file-or-directory-during-gulp-ruby-sass-task

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!