/
Gruntfile.js
163 lines (145 loc) · 4.36 KB
/
Gruntfile.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/*
* brandscale
* http://brandscale.com/
*
* Copyright (c) 2012 Jon Schlinkert
*/
module.exports = function(grunt) {
'use strict';
var theme = grunt.file.readJSON('config/theme.json');
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/* \n' +
' * <%= pkg.name %>.js v<%= pkg.version %> by @jonschlinkert\n' +
' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * ================================================== */\n',
theme: theme,
// Import default project paths.
path: grunt.file.readJSON(theme.paths),
// Override default project paths with custom paths.
defaults: {
root: ".",
src: "<%= defaults.root %>/src"
},
// Templates, build HTML docs from .mustache files
templates: {
options: {
engine: "handlebars",
language: "en-us"
},
project: {
options: {
production: false,
dev: true,
layout: 'src/templates/layouts/layout.mustache',
partials: [
'src/templates/partials/**/*.mustache',
'src/templates/snippets/**/*.mustache'
],
data: ['src/data/*.json', 'src/templates/**/*.json'],
assets: 'dist/assets'
},
files: {
// Compile each page in the project.
'dist': ['src/templates/pages/*.mustache']
}
},
testDocs: {
options: {
production: false,
dev: true,
layout: 'src/templates/layouts/layout.mustache',
partials: [
'src/templates/partials/**/*.mustache',
'src/templates/snippets/**/*.mustache'
],
data: ['src/data/*.json', 'src/templates/**/*.json'],
assets: 'dist/assets'
},
files: {
'test/html': [
'src/templates/pages/*.mustache'
]
}
},
testDocsExamples: {
options: {
flatten: true,
production: false,
dev: true,
layout: 'src/templates/layouts/layout-basic.mustache',
data: ['src/data/*.json', 'src/templates/**/*.json'],
partials: [
'src/templates/partials/**/*.mustache',
'src/templates/snippets/**/*.mustache'
],
assets: 'dist/assets'
},
files: {
'test/html/examples': ['src/templates/pages/no-layout/*.mustache']
}
},
testPartials: {
options: {
dev: true,
production: false,
layout: 'src/templates/layouts/layout.mustache',
partials: [
'src/templates/partials/**/*.mustache',
'src/templates/snippets/**/*.mustache'
],
data: ['src/data/*.json', 'src/templates/**/*.json'],
assets: 'dist/assets'
},
files: {
'test/html/components': ['src/templates/partials/**/*.mustache']
}
}
},
watch: {
lib: {
files: [
'src/templates/pages',
'src/templates/partials',
'src/templates/snippets',
'src/templates/layouts'
],
tasks: ['nodeunit']
}
},
subgrunt: {
themes: ['themes/**/Gruntfile.js']
}
});
// Load npm plugins to provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-contrib-less');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-recess'); // broken due to changes in grunt v0.4.0, temporarily pulling from forked (and fixed) repo
// Load local tasks.
grunt.loadTasks('tasks');
// Default task.
grunt.registerTask('default', [
'templates'
]);
// Run sub-grunt files in all projects.
grunt.registerMultiTask('subgrunt', 'Run a sub-gruntfile.', function() {
var path = require('path');
var files = grunt.file.expandFiles(this.file.src);
grunt.util.async.forEachSeries(files, function(gruntfile, next) {
grunt.util.spawn({
grunt: true,
args: ['--gruntfile', path.resolve(gruntfile)]
}, function(error, result) {
if (error) {
grunt.log.error(result.stdout).writeln();
next(new Error('Error running sub-gruntfile "' + gruntfile + '".'));
} else {
grunt.verbose.ok(result.stdout);
next();
}
});
}, this.async());
});
};