Menggabungkan file HTML
Plugin
Struktur Folder
proyek/
|-- inc/
| |-- header.html
| |-- footer.html
|-- pages/
| |-- index.html
| |-- about.html
|-- dist/
| |-- index.html
| |-- about.html
|-- gulpfile.js
Gulpfile.js
var gulp = require('gulp');
var fileInclude = require('gulp-file-include');
gulp.task('html', function() {
return gulp.src('pages/*.html')
.pipe(fileInclude())
.pipe(gulp.dest('dist'));
});
gulp.task('default', ['html']);
<!DOCTYPE html>
<head>
<title>@@title</title>
</head>
<html>
<body>
</body>
</html>
index.html
@@include('../header.html', {
'title': 'Utama'
})
<h1>Index.html</h1>
@@include('../footer.html')
about.html
@@include('../header.html', {
'title': 'Tentang'
})
<h1>About.html</h1>
@@include('../footer.html')