Gulpfile.js file:
var gulp = require (' Gulp '),
Htmlmin = require (' gulp-htmlmin ');
Gulp.task (' Default ', function () {
Put your default task code here.
Const OPTIONS = {
Removecomments:true,//Clear HTML comment
Collapsewhitespace:true,//Compressed HTML
Collapsebooleanattributes:true,//omitting the value of the Boolean property <input checked= "true"/> ==> <input, checked/>
Removeemptyattributes:true,//Remove all spaces for attribute value <input id= ""/> ==> <input/>
Removescripttypeattributes:true,//delete <script> type= "Text/javascript"
Removestylelinktypeattributes:true,//delete <style> <link> type= "Text/css"
Minifyjs:true,//Compressed page JS
Minifycss:true//Compressed page CSS
};
Return gulp.src (' *.html ')
. Pipe (Htmlmin (options))
. Pipe (Gulp.dest (' *.min.html '));
});
The top function can be adjusted as needed, such as when I use only the MINIFYCSS option.
Create a good gulpfile.css in the folder, as long as cmd, and then download the Gulp related components, and then run gulp can be