The following example will parse the build blocks in the HTML, replace them and pass those files through. Assets inside the build blocks will be concatenated and passed through in a stream as well.
var gulp = require('gulp'),
useref = require('gulp-useref');
gulp.task('default', function () {
return gulp.src('app/*.html')
.pipe(useref()) //有没有这句话似乎没什么影响
.pipe(gulp.dest('dist'));
});
它可以把html里零碎的这些引入合并成一个文件,但是它不负责代码压缩。
An example of this in completed form can be seen below:
The resulting HTML would be: