简体   繁体   中英

Run gulp on changed files in jade

I have gulp watching jade prototypes in a /source folder, structure as follows:

/source/prototypes/my-prototype-1/index.jade
/source/prototypes/my-prototype-2/index.jade

Here's the gulp task:

gulp.task('jade', function() {
    return gulp.src(['source/**/*.jade'])
    .pipe(changed('build/prototypes/', {extension: '.html'}))
    .pipe(jade({
        pretty: true
    }))
    .pipe(gulp.dest('build'))
    .on('error', gutil.log)
    .pipe(notify({ message: 'Jade task is complete' }));
});

The prototypes are compiled into:

/build/prototypes/my-prototype-1/index.jade
/build/prototypes/my-prototype-2/index.jade

The problem is that all prototypes are still getting re-compiled when any of them is changed. Is this perhaps because of the way I'm nesting the prototypes in folders?

The gulp-changed documentation says that the first parameter is

The destination directory. Same as you put into gulp.dest().

Try to replace the line

.pipe(changed('build/prototypes/', {extension: '.html'}))

with

.pipe(changed('build', {extension: '.html'}))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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