const gulp = require("gulp");
const minHTML = require('gulp-htmlmin');
gulp.task("htmlMin", function () {
return (
gulp
.src("./*.html")
.pipe(minHTML({ collapseWhitespace: true }))
.pipe(gulp.dest("dist"))
);
});
exports.default = gulp.series("htmlMin");
并且只需要
gulp
在命令行。
使用
gulp-htmlmin
正如@Cully在评论中建议的那样,我已经做到了。
~/replace ==> gulp
[01:23:36] Using gulpfile ~\OneDrive\Test Bed\replace\gulpfile.js
[01:23:36] Starting 'default'...
[01:23:36] Starting 'htmlMin'...
[01:23:36] Finished 'htmlMin' after 127 ms
[01:23:36] Finished 'default' after 132 ms