-
Notifications
You must be signed in to change notification settings - Fork 36
/
grunt.js
90 lines (84 loc) · 2.24 KB
/
grunt.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
concat: {
'app/public/css/bundle/tt.css': [
'app/public/css/yui-reset.css',
'app/public/css/app.css'
],
'app/public/js/bundle/tt.js': [
'app/public/js/*.js'
],
'app/public/js/bundle/lib.js': [
'app/public/js/lib/jquery-1.8.3.min.js',
'app/public/js/lib/jquery-ui-1.9.2.custom.min.js',
'app/public/js/lib/jquery.*.js',
'app/public/js/lib/hogan.js'
]
},
hogan: {
compile: {
namespace: 'HoganTemplates',
src: ['app/views/templates/*.html'],
dest: 'app/public/js/bundle/hoganTemplates.js'
}
},
min: {
dist: {
src: ['app/public/js/bundle/tt.js'],
dest: 'app/public/js/bundle/tt.min.js'
}
},
lint: {
all: ['app/public/js/*.js']
},
jshint: {
options: {
browser: true,
curly: true,
eqeqeq: true,
evil: true,
forin: true,
indent: 2,
jquery: true,
quotmark: 'single',
undef: true,
unused: false,
trailing: true
},
globals: {
TT: true,
Hogan: true,
HoganTemplates: true
}
},
watch: {
files: [
'app/public/css/*',
'app/public/js/*',
'app/views/templates/*'
],
tasks: 'default'
}
});
grunt.registerMultiTask('hogan', 'Pre-compile hogan.js templates', function () {
var Hogan = require('hogan.js');
var path = require('path');
var data = this.data;
var namespace = data.namespace || 'HoganTemplates';
var output = 'var ' + namespace + ' = {};';
grunt.file.expand(data.src).forEach(function (template) {
var name = path.basename(template, path.extname(template));
try {
output += "\n" + namespace + "['" + name + "'] = " +
Hogan.compile(grunt.file.read(template).toString(), { asString: true }) + ';';
} catch (error) {
grunt.log.writeln('Error compiling template ' + name + ' in ' + template);
throw error;
}
});
grunt.file.write(data.dest, output);
});
// Default task.
grunt.registerTask('default', 'lint hogan concat min');
};