carlitoplatanito / gulp-nunjucks-render

[Gulp](https://github.com/wearefractal/gulp) plugin to render [Nunjucks](http://mozilla.github.io/nunjucks/) templates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

reloading for each template with browsersync

stevenMouret opened this issue · comments

Hi,

I have a front-end workflow with Nunjucks template, SASS and Browsersync.
For some time, the compilation of Nunjucks bug with Browsersync. Before when I ran Gulp, Browsersync reloaded one time the Nunjcuks files. Now Browsersync reload as many time as there are Nunjucks files.

I notice that there were changes with version of Lodash library, can that come from that?

My Nunjucks task :

var siteRoot = './';
var siteSources = 'sources_fe/';
var render = siteRoot + 'render/';
var templatesFolder = siteSources + 'templates/';
var templatesInput = templatesFolder + '**/*.njk';

gulp.task('njk', function () {
    return gulp.src(templatesInput)
        .pipe(nunjucksRender({
            path: templatesFolder,
            ext:  '.html'
        }))
        .pipe(gulp.dest(render))
        .pipe(reload({stream: true}));
});

Thank you for your help.

I have found the problem, this does not come from Nunjucks render but from Browsersync.

I change my task for reload browser only when Nunjucks files are compiled.

gulp.task('njk', function () {
    return gulp.src(templatesInput)
        .pipe(nunjucksRender({
            path: templatesFolder,
            ext:  '.html'
        }))
        .pipe(gulp.dest(render));
});

gulp.task('njk-watch', ['njk'], function (done) {
    browserSync.reload();
    done();
});

And watcher call the task 'njk-watch'