mjmlio / gulp-mjml

Add Gulp to your MJML workflow!
MIT License
161 stars 37 forks source link

gulp compiles only the first time #52

Closed baronetto closed 4 years ago

baronetto commented 4 years ago

Hi, I'm new to mjml and I'm trying to setup gulp. I've installed the plugin and added code in my gulpfile so that gulp watches for any changes to .mjml files

  return src(source, { base: "./" })
    .pipe(mjml())
    .on("error", reportError)
    .pipe(gulp.dest("."));

When I update a .mjml file, gulp does detect the changes and compiles the template but only once. When I make another change and hit save, nothing happens.

Any ideas what could be going on?

iRyusa commented 4 years ago

You need to use a plugin like gulp watch to have this behavior.

On 7 Jan 2020, at 02:23, Panos Spiliotis notifications@github.com wrote:

 Hi, I'm new to mjml and I'm trying to setup gulp. I've installed the plugin and added code in my gulpfile so that gulp watches for any changes to .mjml files

return src(source, { base: "./" }) .pipe(mjml()) .on("error", reportError) .pipe(gulp.dest(".")); When I update a .mjml file, gulp does detect the changes and compiles the template but only once. When I make another change and hit save, nothing happens.

Any ideas what could be going on?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

baronetto commented 4 years ago

Thank you for the quick reply! I do use watch and it gets intialized properly in the default task. The problem is that any changes are detected only once for mjml whereas for other tasks (sass, js etc.) it works just fine after saving any change.

watch("templates/**/*.mjml", function() {
    mjml();   
  });
iRyusa commented 4 years ago

Just share your entire gulp file here we can’t really help you.

On 7 Jan 2020, at 04:45, Panos Spiliotis notifications@github.com wrote:

 Thank you for the quick reply! I do use watch and it gets intialized properly in the default task because. The problem is that any changes are detected only once for mjml whereas for other tasks (sass, js etc.) it works just fine after saving any change.

watch("templates/*/.mjml", function() { mjml();
}); — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

iRyusa commented 4 years ago

This is not how watch works : https://www.npmjs.com/package/gulp-watch#usage

watch("templates/**/*.mjml")
  .pipe(mjml())
  .pipe(gulp.dest("."))

It should be something like this