-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
61 lines (55 loc) · 2.27 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
var gulp = require('gulp');
var less = require('gulp-less');
var wrap = require('gulp-wrap');
var concat = require('gulp-concat');
var declare = require('gulp-declare');
var handlebars = require('gulp-handlebars');
var sourcemaps = require('gulp-sourcemaps');
var exec = require('child_process').exec;
gulp.task('templates', function () {
// Load templates from the client/templates/ folder relative to where gulp was executed
gulp.src('resources/handlebars/**/*.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: 'App.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(/resources[\\/]handlebars[\\/]/gi, ''));
}
}))
// Concatenate down to a single file
.pipe(concat('templates.js'))
// Write the output into the build folder
.pipe(gulp.dest('public/js/'));
});
gulp.task('less', function () {
gulp.src('resources/assets/less/**/*.less')
.pipe(sourcemaps.init())
.pipe(less({
//paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('public/css/'));
});
gulp.task('composer', function (cb) {
exec('composer install', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('bower', function (cb) {
exec('bower install --allow-root', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
gulp.task('default', ['templates', 'less', 'composer', 'bower']);