Answer the question
In order to leave comments, you need to log in
How to remove comments when minifying HTML?
I use gulp-htmlmin for minification . But, if there are comments in the code, then they remain in the form in which they were originally. For example, there are blocks of commented out code that is not compressed in any way.
I can't figure out if it's possible to configure gulp-htmlmin to remove or compress HTML comments.
Task code:
gulp.task('html', function () {
return gulp.src('src/*.html')
.pipe(include())
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest('dist'))
.pipe(browserSync.reload({stream: true}));
});
Answer the question
In order to leave comments, you need to log in
as an option
var gulp = require('gulp');
var removeHtmlComments = require('gulp-remove-html-comments');
gulp.task('html', function () {
return gulp.src('src/*.html')
.pipe(removeHtmlComments())
.pipe(gulp.dest('dist'));
});
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
https://github.com/kangax/html-minifier#options-qu...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question