Gulp Task Watch with Jekyll,gulpfile.babel.js

时间:2018-05-18 11:30:05

标签: gulp jekyll babel

我想知道我的内容是否可以简化,似乎有点重复,但我无法弄清楚如何以不同的方式同时运行所有文件观察者。

感谢任何帮助:

let files = {
    html: './*.html',
    htmlDeeper: './*/*/.html',
    css:  './_assets/css/*.scss',
    cssDeeper: './_sass/*/*.scss',
    js:   './*.js',
    jsDeeper: './_assets/js/*.js',
    yml:  './_config.yml'
};

// Watch for file changes

gulp.task('watch', () => {
    gulp.watch(files.html, ['jekyll-reload']);
    gulp.watch(files.htmlDeeper, ['jekyll-reload']);
    gulp.watch(files.css, ['jekyll-reload']);
    gulp.watch(files.cssDeeper, ['jekyll-reload']);
    gulp.watch(files.js, ['jekyll-reload']);
    gulp.watch(files.jsDeeper, ['jekyll-reload']);
    gulp.watch(files.yml, ['jekyll-reload']);
});   

1 个答案:

答案 0 :(得分:1)

let files = {

    html: './**/**/*.html',
    // htmlDeeper: './*/*/.html',

    // it isn't clear if this will work for you
    //   perhaps you are trying to exclude something like './other/*.scss' ?
    // css: '/**/*.scss'

    css:  './_assets/css/*.scss',
    cssDeeper: './_sass/*/*.scss',

    // same comment as above, if you are trying to not include something like
    //  './otherFolder/js/*.js' than the next line would work

    //  js: '/**/*.js',

    js:   './*.js',
    jsDeeper: './_assets/js/*.js',

    yml:  './_config.yml'
};


// gulp.watch(files.htmlDeeper, ['jekyll-reload']);