juanfran / gulp-jade-inheritance

Gulp plugin to rebuild jade files and other files that have extended or included those files
34 stars 32 forks source link

Jade includes/extends are not considered on watch task #9

Closed pure180 closed 8 years ago

pure180 commented 8 years ago

Maybe Iam doing something wrong, but using a template based jade build environment with subfolder, includes and extendsare not considered on watch task when saving them.

Maybe you can take a look at it, thanks in advanced.

My build Enviroment

src
-- jade
----- layouts
-------- default.jade
----- partials
-------- mypartial.jade
----- templates
-------- index.jade

My gulpfile.js

'use-strict';

var gulp = require('gulp');
var jade = require('gulp-jade');
var changed = require('gulp-changed');
var cached = require('gulp-cached');
var gulpif = require('gulp-if');
var filter = require('gulp-filter');
var jadeInheritance = require('gulp-jade-inheritance');

gulp.task('jade', function(){
  return gulp.src( './src/jade/templates/**/*.jade' )
    .pipe(changed('dist', {extension: '.html'}))
    .pipe(gulpif(global.isWatching, cached('jade')))
    .pipe(jadeInheritance({basedir: 'src/jade/templates'}))
    .pipe(filter(function (file) {
      return !/\/_/.test(file.path) || !/^_/.test(file.relative);
    }))
    .pipe(jade({
      pretty: true
    }))
    .pipe(gulp.dest( 'dist' ))
});

gulp.task('setWatch', function() {
  global.isWatching = true;
});

gulp.task('watch', [ 'setWatch', 'jade'], function() {
  gulp.watch( 'src/jade/**/*.jade', ['jade']);
});
juanfran commented 8 years ago

change gulp.src( './src/jade/templates/**/*.jade' ) for gulp.src( './src/jade/**/*.jade' ), gulp-changed should be able to see all the jade files