forked from less/less-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
222 lines (198 loc) · 5.23 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/*
* lesscss.org <https://github.com/less/less-docs>
*
* Copyright (c) 2017, Alexis Sellier, Less Core Team, contributors.
* Licensed under the MIT license.
*/
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Project metadata
pkg: grunt.file.readJSON('package.json'),
_less: grunt.file.readJSON('data/less.json'),
site: grunt.file.readYAML('.assemblerc.yml'),
download: {
package: {
src: 'https://raw.githubusercontent.com/less/less.js/master/packages/less/package.json',
dest: 'data/less.json'
}
},
jshint: {
options: {
jshintrc: '.jshintrc'
},
all: ['Gruntfile.js', '<%= site.helpers %>/*.js']
},
// Pull down a JSON list of repos from the Less org, using
// GitHub's API (to be passed as context into the templates)
repos: {
namespaced: {
options: {username: 'less'},
files: {
'<%= site.data %>/less.json': ['repos?page=1&per_page=100']
}
}
},
// Build HTML from templates and data
assemble: {
options: {
flatten: true,
production: false,
assets: '<%= site.dest %>/public',
// Metadata
pkg: '<%= pkg %>', // extend the context with `pkg`
site: '<%= site %>', // extend the context with `site`
less: '<%= _less %>', // extend the context with `less`
data: ['<%= site.data %>/*.{json,yml}', 'content/**/*.json'],
// Templates
partials: '<%= site.includes %>/*.hbs',
layoutdir: '<%= site.layouts %>',
layoutext: '<%= site.layoutext %>',
layout: '<%= site.layout %>',
// Extensions
// mixins: ['<%= site.mixins %>/utils.js'],
helpers: ['<%= site.helpers %>/*.js'],
plugins: ['<%= site.plugins %>'],
// `compose` helper options
compose: {cwd: 'content'},
// markdown options
marked: {
process: true,
heading: '<%= site.snippets %>/heading.tmpl',
// highlight.js options
prefix: 'lang-'
}
},
site: {
options: {
permalinks: {preset: 'pretty'},
partials: ['content/**/*.md']
},
src: '<%= site.pages %>/*.hbs',
dest: '<%= site.dest %>/'
},
feed: {
options: {ext: '.xml', layout: 'none'},
src: '<%= site.snippets %>/feed.xml',
dest: '<%= site.dest %>/'
}
},
prettify: {
site: {
files: [
{
expand: true,
cwd: '<%= site.dest %>',
src: '*.html',
dest: '<%= site.dest %>/',
ext: '.html'
}
]
}
},
connect: {
options: {
port: 9000,
livereload: 35729,
hostname: 'localhost'
},
livereload: {
options: {
open: true,
base: ['<%= site.dest %>']
}
}
},
// Compile Less to CSS
less: {
options: {
paths: ['styles/bootstrap', 'styles/components']
},
site: {
src: ['styles/index.less'],
dest: '<%= assemble.options.assets %>/css/index.css'
}
},
// Copy source assets to _gh_pages
copy: {
assets: {
files: [
{
expand: true,
cwd: '<%= site.assets %>/public',
src: ['**'],
dest: '<%= site.dest %>/public/'
},
{
expand: true,
cwd: '<%= site.assets %>/root',
src: ['*'],
dest: '<%= site.dest %>/',
rename: function (dest, src) {
dest = dest + src.replace(/^_/, '');
return dest;
}
}
]
}
},
clean: {
example: ['<%= site.dest %>/*']
},
watch: {
options: {livereload: true },
styles: {
files: ['<%= site.styles %>/**/*.less'],
tasks: ['less:site']
},
content: {
files: ['<%= site.content %>/**/*.md'],
tasks: ['assemble:site']
},
templates: {
files: ['<%= site.templates %>/**/*.hbs'],
tasks: ['assemble:site']
},
data: {
files: ['<%= site.data %>/*.{json,yml}'],
tasks: ['assemble:site']
},
assets: {
files: ['<%= site.assets %>/**/*.*'],
tasks: ['copy']
}
}
});
// Load npm plugins to provide necessary tasks.
grunt.loadNpmTasks('assemble');
grunt.loadNpmTasks('assemble-less');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-prettify');
grunt.loadNpmTasks('grunt-repos');
grunt.loadNpmTasks('grunt-sync-pkg');
grunt.loadNpmTasks('grunt-http-download');
grunt.registerTask('update', ['repos', 'default']);
grunt.registerTask('design', [
'clean',
'download',
'copy',
'less:site',
'assemble:site',
'connect',
'watch'
]);
// Default tasks to be run.
grunt.registerTask('default', [
'jshint',
'clean',
'download',
'copy',
'less:site',
'assemble:site'
]);
};