simon-dt / gulp-twig

Twig plugin for gulp.js, The streaming build system. Looking for maintainer or collaborators. See wiki
https://github.com/zimmen/gulp-twig/wiki/Looking-for-maintainer-or-collaborator(s)
MIT License
62 stars 33 forks source link

How to use with watch? #2

Closed camilleb closed 10 years ago

camilleb commented 10 years ago

Hi,

I'm new to gulp, and I try to use your plugin. It works really well, but I can't use it with gulp.watch.

I mean is there a sort of cache I can desactivate or anything? When I run my gulp command, it sees the change in twig files, but it compiles it from the old files (may be the file's state when I launched the command).

Here's the code I have:

//--- TWIG
gulp.task('twig', function () {
  'use strict';
  return gulp.src(['./views/index.twig'])
    .pipe(twig())
    .pipe(gulp.dest('./html/'))
    .pipe(livereload());
});

//--- WATCH
gulp.task('watch', function() {
    gulp.watch('./views/*.twig', ['twig']);
});

gulp.task('default', ['twig', 'watch']);

Thanks for your help!

simon-dt commented 10 years ago

Hi Camille,

I have the exact same behavior. It seems the input file doesn't change after the first run. Could you verify that it does work on the first change and that ik keeps working when doing a manual gulp twig ?

I will look into this this evening, thanks for reporting the issue :-)

camilleb commented 10 years ago

Hi Simon, Yes it works fine when I do a manuel gulp twig.

If I can help with anything tell me! I saw Twig.cache = true; in l.30 twig.js, do you think it can be related to that?

simon-dt commented 10 years ago

Yes, Twig.js defaults to caching for performance. gulp-twig 0.0.2 now disables this unless you pass cache:true as an option. Thanks!

camilleb commented 10 years ago

\o/ Thanks a lot!