1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 | 'use strict';
|
10 |
|
11 | module.exports = function(grunt) {
|
12 |
|
13 | grunt.initConfig({
|
14 | clean: {
|
15 | tests: 'tmp'
|
16 | },
|
17 | nodeunit: {
|
18 | tests: ['test/*.js']
|
19 | },
|
20 | watch: {
|
21 | tests: '<%= nodeunit.tests %>',
|
22 | tasks: 'default'
|
23 | },
|
24 | jshint: {
|
25 | all: ['Gruntfile.js', 'tasks/**/*.js', '<%= nodeunit.tests %>'],
|
26 | options: {
|
27 | curly: true,
|
28 | eqeqeq: true,
|
29 | immed: true,
|
30 | latedef: true,
|
31 | newcap: true,
|
32 | noarg: true,
|
33 | sub: true,
|
34 | undef: true,
|
35 | boss: true,
|
36 | eqnull: true,
|
37 | node: true,
|
38 | es5: true
|
39 | },
|
40 | globals: {}
|
41 | },
|
42 | concat: {
|
43 | custom_concat: {
|
44 | src: 'test/fixtures/one.html',
|
45 | dest: 'tmp/custom_concat_combined.js',
|
46 | options: {
|
47 | separator: '\n\n'
|
48 | }
|
49 | }
|
50 | },
|
51 |
|
52 |
|
53 | ngtemplates: {
|
54 |
|
55 | custom_angular: {
|
56 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
57 | dest: 'tmp/custom_angular.js',
|
58 | options: {
|
59 | angular: 'myAngular'
|
60 | }
|
61 | },
|
62 |
|
63 |
|
64 | custom_bootstrap: {
|
65 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
66 | dest: 'tmp/custom_bootstrap.js',
|
67 | options: {
|
68 | bootstrap: function(module, script) {
|
69 | return 'module.exports = function($templateCache) {\n' + script + '\n};\n';
|
70 | }
|
71 | }
|
72 | },
|
73 |
|
74 |
|
75 | custom_concat: {
|
76 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
77 | dest: 'tmp/custom_concat.js',
|
78 | options: {
|
79 | concat: 'custom_concat'
|
80 | }
|
81 | },
|
82 |
|
83 |
|
84 | custom_htmlmin: {
|
85 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
86 | dest: 'tmp/custom_htmlmin.js',
|
87 | options: {
|
88 | htmlmin: {
|
89 | collapseBooleanAttributes: true,
|
90 | collapseWhitespace: true,
|
91 | removeAttributeQuotes: true,
|
92 | removeComments: true,
|
93 | removeEmptyAttributes: true,
|
94 | removeRedundantAttributes: true,
|
95 | removeScriptTypeAttributes: true,
|
96 | removeStyleLinkTypeAttributes: true
|
97 | }
|
98 | }
|
99 | },
|
100 |
|
101 |
|
102 | task_htmlmin: {
|
103 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
104 | dest: 'tmp/task_htmlmin.js',
|
105 | options: {
|
106 | htmlmin: '<%= ngtemplates.custom_htmlmin.options.htmlmin %>'
|
107 | }
|
108 | },
|
109 |
|
110 |
|
111 | default_module: {
|
112 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
113 | dest: 'tmp/default_module.js'
|
114 | },
|
115 |
|
116 |
|
117 | custom_module: {
|
118 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
119 | dest: 'tmp/custom_module.js',
|
120 | options: {
|
121 | module: 'customModule'
|
122 | }
|
123 | },
|
124 |
|
125 |
|
126 | callback_module: {
|
127 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
128 | dest: 'tmp/callback_module.js',
|
129 | options: {
|
130 | module: function(url, options) {
|
131 | return url.split('/').join('.');
|
132 | },
|
133 | url: function(file) {
|
134 | return file.replace('.html', '');
|
135 | }
|
136 | }
|
137 | },
|
138 |
|
139 |
|
140 | custom_source: {
|
141 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
142 | dest: 'tmp/custom_source.js',
|
143 | options: {
|
144 | source: function(source, url) {
|
145 | return "<!-- Template: " + url + " -->\n" + source;
|
146 | }
|
147 | }
|
148 | },
|
149 |
|
150 |
|
151 | standalone: {
|
152 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
153 | dest: 'tmp/standalone.js',
|
154 | options: {
|
155 | standalone: true
|
156 | }
|
157 | },
|
158 |
|
159 |
|
160 | full_url: {
|
161 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
162 | dest: 'tmp/full_url.js'
|
163 | },
|
164 |
|
165 |
|
166 | relative_url: {
|
167 | cwd: 'test/fixtures',
|
168 | src: ['one.html', 'two/**/*.html'],
|
169 | dest: 'tmp/relative_url.js'
|
170 | },
|
171 |
|
172 |
|
173 | custom_url: {
|
174 | src: ['test/fixtures/one.html', 'test/fixtures/two/**/*.html'],
|
175 | dest: 'tmp/custom_url.js',
|
176 | options: {
|
177 | url: function(url) {
|
178 | return url.replace('.html', '');
|
179 | }
|
180 | }
|
181 | },
|
182 |
|
183 |
|
184 | empty_file: {
|
185 | src: 'test/fixtures/empty.html',
|
186 | dest: 'tmp/empty_file.js'
|
187 | },
|
188 |
|
189 |
|
190 | undefined_file: {
|
191 | src: 'test/fixtures/undefined.html',
|
192 | dest: 'tmp/undefined_file.js'
|
193 | }
|
194 | }
|
195 | });
|
196 |
|
197 |
|
198 | grunt.loadTasks('tasks');
|
199 | grunt.loadNpmTasks('grunt-contrib-clean');
|
200 | grunt.loadNpmTasks('grunt-contrib-concat');
|
201 | grunt.loadNpmTasks('grunt-contrib-jshint');
|
202 | grunt.loadNpmTasks('grunt-contrib-nodeunit');
|
203 |
|
204 | grunt.registerTask('default', ['jshint', 'clean', 'ngtemplates', 'concat', 'nodeunit']);
|
205 | };
|