0

I'm using gulp-newer on my project to check which html file have been updating, and to prevent the reload of every html file in the project.

Everything is working fine except the partial files.

If I edit something in a partial the file will be update correctly but the file in which I call the partial won't be update.

I saw that there is an options.extra with gulp-newer but can't make this work.

My idea is to reload every html files if I update something in one of the partials, and keep the single file reload if I work on a basic file.

Here my task:

// COMPILE SLIM TO HTML
// ---------------------------------------------------------
gulp.task('slim', function () {
  return gulp.src(slim_dev + '/**/*.slim')
    // prevent server from crashing
    .pipe(plugins.plumber({ errorHandler: function(err) {
      plugins.notify.onError({
          title: "Gulp error in " + err.plugin
      })(err);
    }}))
    // compile slim to html
    .pipe(plugins.slim({
      pretty: false,
      include: true
    }))

    .pipe(plugins.newer('build/views/'))
    // minify html
    .pipe(plugins.minifyHtml())
    // copy result to build folder
    .pipe(gulp.dest(slim_build))
    // reload server on slim save
    .pipe(stream({once:true}))
    // notify when task completed
    .pipe(plugins.notify('Slim compilation completed !'));
});
Rob
  • 14,746
  • 28
  • 47
  • 65
Victor Allegret
  • 2,344
  • 3
  • 18
  • 31
  • Take a look at https://www.npmjs.com/package/gulp-sass-partials-imported it is supposed to add the files that import the changed partial into the stream. – Mark Oct 02 '17 at 16:55
  • Do you if this plugin work only with sass file ? I need something similar for slim (html template) – Victor Allegret Oct 02 '17 at 16:59
  • Oh sorry, I saw "partials" and just went to sass. No, I doubt it works with slim files. – Mark Oct 02 '17 at 17:07
  • Poor documentation but I would say it is .newer({extra : slim_dev + '/**/*.slim', dest: 'build/views/'}) if you want to use that option. – Mark Oct 02 '17 at 17:26
  • I tried a lot of things but nothings seems to work, when I try to use the extra option, the global newer pipe stop working :/ – Victor Allegret Oct 02 '17 at 18:04

0 Answers0