-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
40 lines (32 loc) · 1013 Bytes
/
gulpfile.babel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import gulp from 'gulp';
import rename from 'gulp-rename';
import assemble from 'assemble';
import handlebarsHelpers from 'handlebars-helpers';
import prettify from 'gulp-prettify';
const app = assemble();
const options = {
locale: 'en-GB',
assets: './build/media/img/'
};
gulp.task('html', () => {
// Find layouts and partials
app.layouts('./src/hbs/layouts/**/**/*.hbs');
app.partials('./src/hbs/components/**/**/*.hbs');
// Add data
app.data('./src/hbs/json/**/**/*.json');
app.data({ imagePath: './build/media/img/' });
app.data({ name: 'Site' });
// Add classic helpers
app.helpers(handlebarsHelpers(), app.helpers);
// Add options
app.option('layout', 'default.hbs');
// Build templates
return app.src('./src/hbs/pages/*.hbs')
.pipe(app.renderFile(options))
.pipe(rename({ extname: '.html' }))
.pipe(prettify({ indent_size: 2 }))
.pipe(app.dest('./build/'));
});
gulp.task('watch', () => {
gulp.watch('./src/hbs/**/**/**/*.{hbs,json}', ['html']);
});