htmlone combo ; gulp组件,功能和 grunt 版本的 htmlone 一致
combo and minify css
and js
to html. no matter the file is online or not.
One-Request集成解决方案之一,厂内同学请移步Group:One-Request
var gulp = require('gulp');
var htmlone = require('gulp-htmlone');
gulp.task('htmlone', function() {
gulp.src(['./*.html'])
.pipe(htmlone())
.pipe(gulp.dest('./dest'));
});
then gulp will combo the content of <script >
and <link rel="stylesheet" />
tags to the dest html doc.
gulp.src('./src/*.html')
.pipe(htmlone({
removeSelector: '[will-remove]', // selector 配置,源文档中符合这个selector的标签将自动移除
keepliveSelector: '[keeplive]', // 不要combo的selector配置,源文档中符合这个selector的将保持原状
destDir: './', // dest 目录配置,一般情况下需要和 gulp.dest 目录保持一致,用于修正相对路径资源
coimport: true, // 是否需要把 @import 的资源合并
cssminify: true, // 是否需要压缩css
jsminify: true // 是否需要压缩js
}))
// ...
MIT
mkdirp
的问题removeSelector
配置Usage
keyattr
配置,改为 keepliveSelector
,标识指定selector
不执行combo操作destDir
配置,用于当destFile和sourceFile不在一级目录的时候,css等资源内联后内部url相对路径资源修正coimport
配置,用于选择是否需要将css 中 @import
进行combile后再内联至html文档。支持@import 递归 和 http url 的import 以及路径修正temp
变为 htmlone_temp
,temp目录太通用,容易冲突ycssmin
, 避免windows环境下dataurl less处理的路径bug。//aaa.com
的处理问题\x3c/script>
解成 </script>
导致内联script脚本非预期截断的问题