这实际上是尝试使用它:https://github.com/shakyShane/jekyll-gulp-sass-browser-sync/blob/master/gulpfile.js和命名函数。无论出于何种原因,jekyllrebuild任务将启动但未完成。当我更改.html或.markdown时,控制台会输出以下内容:
[11:06:10] Starting 'jekyllrebuild'...
[BS] Reloading Browsers...
除此之外它运作良好,不确定为什么重建任务会挂起。任何帮助非常感谢,gulpfile下面。谢谢!
var browsersync = require('browser-sync');
var cp = require('child_process');
var gulp = require('gulp');
var gutil = require('gulp-util');
var sass = require('gulp-sass');
var paths = {
html: {
src: './app/**/*.html',
},
jekyll: {
src: './app',
dist: './_site',
},
markdown: {
src: './app/**/*.markdown',
},
styles: {
src: './app/_sass/**/*.scss',
dist: './app/css',
}
};
gulp.task(jekyllbuild);
gulp.task(jekyllrebuild, gulp.series(jekyllbuild));
gulp.task(serve);
gulp.task(styles);
gulp.task(watch);
gulp.task('default',
gulp.series(
styles,
jekyllbuild,
gulp.parallel(serve, watch))
);
function jekyllbuild(done) {
browsersync.notify('building jekyll');
return cp.spawn('jekyll.bat', ['build'], {stdio: 'inherit'})
.on('close', done);
}
function jekyllrebuild() {
browsersync.reload();
};
function serve() {
browsersync.init({
server: paths.jekyll.dist,
notify: true
})
}
function styles() {
return gulp.src(paths.styles.src)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(paths.jekyll.dist + '/css'))
.pipe(browsersync.stream())
.pipe(gulp.dest(paths.styles.dist))
}
function watch() {
gulp.watch(paths.styles.src, styles);
gulp.watch(paths.html.src, jekyllrebuild);
gulp.watch(paths.markdown.src, jekyllrebuild);
}
答案 0 :(得分:0)
这一行是无稽之谈:
gulp.task(jekyllrebuild, gulp.series(jekyllbuild));
您无法将两个功能传递给gulp.task()
。查看gulp 3.x task that you linked您可能需要gulp 4.x中的以下内容:
gulp.task('jekyllrebuild', gulp.series(jekyllbuild, function(cb) {
browsersync.reload();
cb();
}));
function watch() {
gulp.watch(paths.styles.src, styles);
gulp.watch(paths.html.src, gulp.series('jekyllrebuild'));
gulp.watch(paths.markdown.src, gulp.series('jekyllrebuild'));
}