-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathgulpfile.js
31 lines (30 loc) · 1.4 KB
/
gulpfile.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
var gulp = require('gulp');
var wrap = require('gulp-wrap');
var concat = require('gulp-concat');
var declare = require('gulp-declare');
/** REMOVE ME **/ var handlebars = require('../../');
/** USE ME **/ // var handlebars = require('gulp-handlebars');
// Default task
gulp.task('default', function() {
// Load templates from the client/templates/ folder relative to where gulp was executed
return gulp.src('client/templates/**/*.hbs')
// Compile each Handlebars template source file to a template function
.pipe(handlebars())
// Wrap each template function in a call to Handlebars.template
.pipe(wrap('Handlebars.template(<%= contents %>)'))
// Declare template functions as properties and sub-properties of MyApp.templates
.pipe(declare({
namespace: 'MyApp.templates',
noRedeclare: true, // Avoid duplicate declarations
processName: function(filePath) {
// Allow nesting based on path using gulp-declare's processNameByPath()
// You can remove this option completely if you aren't using nested folders
// Drop the client/templates/ folder from the namespace path by removing it from the filePath
return declare.processNameByPath(filePath.replace('client/templates/', ''));
}
}))
// Concatenate down to a single file
.pipe(concat('templates.js'))
// Write the output into the build folder
.pipe(gulp.dest('build/js/'));
});