-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathGruntfile.js
207 lines (181 loc) · 4.78 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
/*
* blog
* https://github.com/Jon Schlinkert/blog
* Copyright (c) 2013
* Licensed under the MIT license.
*/
'use strict';
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
// Project metadata
pkg : grunt.file.readJSON('package.json'),
vendor: grunt.file.readJSON('.bowerrc').directory,
site : grunt.file.readYAML('_config.yml'),
pages : grunt.file.readJSON('data/pages.json'),
config: {
src: 'src',
dist: '<%= site.dest %>',
bootstrap: '<%= vendor %>/bootstrap/less',
jquery: '<%= vendor %>/jquery',
holder: '<%= vendor %>/holderjs',
highlight: '<%= vendor %>/highlightjs'
},
/**
* Lint JavaScript
*/
jshint: {
all: ['Gruntfile.js', 'helpers/*.js'],
options: {
jshintrc: '.jshintrc'
}
},
/**
* Build HTML from templates and data
*/
assemble: {
options: {
flatten: true,
// Custom property for _config.yml
site: '<%= site %>',
// Extensions
helpers: ['helper-prettify', 'helper-compose', 'templates/helpers/*.js'],
// plugins: ['permalinks'],
permalinks: {
preset: 'pretty'
},
// Templates and data
data: ['data/**/*.{json,yml}'],
partials: ['templates/includes/*.hbs'],
layoutdir: 'templates/layouts',
layout: 'default.hbs',
// Site variables
assets: '<%= site.dest %>/assets',
root: '<%= site.dest %>',
},
// Generate the main pages of the site.
site: {
files: {
'<%= site.dest %>/': ['templates/*.hbs']
}
},
// Generate posts from "./data/pages.json"
blog: {
options: {
pages: '<%= pages.posts %>'
},
files: {
'<%= site.dest %>/': ['templates/index.hbs']
}
},
// Generate posts by forcing Handlebars
// to recognize `.md` files as templates.
blog_alt: {
options: {
layout: 'blog.hbs',
engine: 'handlebars'
},
files: {
'<%= site.dest %>/alt/': ['templates/list.hbs', 'posts/*.md']
}
}
},
/**
* Compile LESS to CSS
*/
less: {
options: {
paths: ['<%= config.bootstrap %>', 'theme/components'],
},
bootstrap: {
src: ['theme/theme.less'],
dest: '<%= assemble.options.assets %>/css/blog.css'
}
},
/**
* Start a connect web server.
*/
connect: {
options: {
port: 9000,
livereload: 35729,
keepalive: true,
hostname: 'localhost'
},
livereload: {
options: {
open: true,
base: [
'<%= config.dist %>'
]
}
}
},
/**
* Copy vendor dist to assets
*/
copy: {
bootstrap: {
expand: true,
cwd: 'vendor/bootstrap/dist/',
src: [
'js/*',
'fonts/*'],
dest: '<%= assemble.options.assets %>/'
},
bootstrapcss: {
expand: true,
cwd: 'vendor/bootstrap/assets/',
src: [
'js/*',
'fonts/*'],
dest: '<%= assemble.options.assets %>/'
},
jquery: {
src: '<%= config.jquery %>/jquery.min.js',
dest: '<%= assemble.options.assets %>/js/jquery.js'
},
holder: {
src: '<%= config.holder %>/holder.js',
dest: '<%= assemble.options.assets %>/js/holder.js'
},
highlight: {
src: '<%= config.highlight %>/highlight.pack.js',
dest: '<%= assemble.options.assets %>/js/highlight.js'
},
},
/**
* Before generating any new files,
* clean out files from previous build.
*/
clean: {
example: ['<%= site.dest %>/**/*.html']
},
/**
* Run predefined tasks whenever watched file
* patterns are added, changed or deleted.
*/
watch: {
all: {
files: ['<%= jshint.all %>'],
tasks: ['jshint', 'nodeunit']
},
design: {
files: ['Gruntfile.js', '<%= less.options.paths %>/*.less', 'templates/**/*.hbs'],
tasks: ['design']
}
}
});
// Load npm plugins to provide necessary tasks.
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('assemble-less');
grunt.loadNpmTasks('assemble');
// Build HTML, compile LESS and watch for changes.
grunt.registerTask('design', ['clean', 'assemble', 'less:bootstrap', 'watch:design', 'connect']);
// Default tasks to be run.
grunt.registerTask('default', ['clean', 'jshint', 'less', 'copy', 'assemble']);
};