gulp提取公用部分
利用gulp-file-include插件实现
gulpfile.js代码
var gulp = require('gulp');
var fileinclude = require('gulp-file-include');
gulp.task('fileinclude',function(){
//适配page所有文件夹下html文件,排除page下的include文件夹的html
gulp.src(['page/**/*.html','!page/include/**.html'])
.pipe(fileinclude({
prefix: '@@',
basepath: '@file'
}))
.pipe(gulp.dest('dist'));
});
模版页面引入代码
@@include('include/header.html')