jonschlinkert / gulp-htmlmin

Minify HTML

Home Page:https://github.com/jonschlinkert

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gulp watch loop

rzb opened this issue · comments

After implementing gulp-htmlmin, gulp watch goes into an endless loop for me.

I'm on Laravel (elixir sits on top of gulp).

elixir.extend('compress', function() {
    new elixir.Task('compress', function() {
        return gulp.src('./storage/framework/views/*')
            .pipe(htmlmin({
                collapseWhitespace          : true,
                collapseInlineTagWhitespace : true,
                removeAttributeQuotes       : true,
                removeComments              : true,
                minifyJS                    : true,
                minifyCSS                   : true,
            }))
            .pipe(gulp.dest('./storage/framework/views/'));
    })
    .watch('./storage/framework/views/*');
});
  1. Try some other HTML processor plugins inside watch task. If you can reproduce infinite loop even when you don't use gulp-htmlmin, this is an issue with elixir.Task#watch.
  2. If you cannot reproduce infinite loop with other plugins, pinpoint the HTML file that causes neverending process and open a new issue on https://github.com/kangax/html-minifier/issues with full content of the HTML file.

@rzb also it looks like your src and dest paths are the same. Since gulp-htmlmin changes the files, watch will trigger.

@doowb Yeah, I noticed that in the following morning with some coffee and have procrastinated since then.

I had copied that snippet directly from this laravel package repo, which is a server side solution to the same problem. So for those who end up here for the same reason:

Replace

.watch('./storage/framework/views/*');

With

.watch('./resources/views/**/*.blade.php');