Gulp循环不迭代

midaym

我正在研究一个新的gulp构建过程,由于某种原因,我无法使其循环播放,它运行得很好,但它只生成第一个少的文件,因此它永远不会迭代。

var files = ['style.less', 'core.less', 'theme.less']
gulp.task('build', function () {
    for (var i = 0; i < files.length; i++) {
        return gulp.src(lessDir + files[i])
        .pipe(plumber({
            errorHandler: onError
        }))
        .pipe(less()).pipe(notify(files[i] + " Rendered!"))
        .pipe(csscomb()).pipe(notify(files[i] + " Sorted!"))
        .pipe(cssbeautify({
            indent: '  ',
            autosemicolon: true
        })).pipe(notify(files[i] + " Spaced!"))
        .pipe(gulp.dest(cssDir))
        .pipe(minifyCSS({
            keepBreaks: false,
            processImport: true,
            noAdvanced: false
        }))
        .pipe(gulp.dest(cssminDir)).pipe(notify(files[i] + " Minified!"));
    }
});
特里·麦克(Trey Mack)

return 将从整体任务中返回,因此循环将仅执行1次迭代。

最好在gulp.src中指定文件,例如gulp.src(files)在更改文件数组以包括lessRir之后。然后让gulp.pipe通过其管道发送每个文件。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章