@wangxingkang
2017-06-15T01:42:01.000000Z
字数 783
阅读 1727
Gulp
目录:
项目地址:gulp-htmlmin
gulp插件html压缩
npm i -D gulp-htmlminyarn add -D gulp-htmlmin
var gulp = require('gulp');var htmlmin = require('gulp-htmlmin');gulp.task('minify', function() {return gulp.src('src/*.html').pipe(htmlmin({collapseWhitespace: true})).pipe(gulp.dest('dist'));});
| 选项 | 描述 | 默认 |
|---|---|---|
| removeComments | 是否去掉注释 | false |
| collapseWhitespace | 是否去掉空格 | false |
| minifyJS | 是否压缩html里的js(使用uglify-js) | false(true, Object, Function(text, inline)) |
| minifyCSS | 是否压缩html里的css(使用clean-css进行的压缩) | false(true, Object, Function(text, inline)) |
| collapseBooleanAttributes | 省略布尔属性的值 | false |
| removeEmptyAttributes | 清除所有的空属性 | false |
| removeScriptTypeAttributes | 清除所有script标签中的type="text/javascript"属性 | false |
| removeStyleLinkTypeAttributes | 删除和的type="text/css" | false |
更多配置请查看html-minifier