-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathGruntfile.js
252 lines (227 loc) · 5.18 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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*
.|'''''| ||
|| . ||
|| |''|| '||''| '|| ||` `||''|, ''||''
|| || || || || || || ||
`|....|' .||. `|..'|. .|| ||. `|..' The JavaScript Task Runner || http://gruntjs.com
*/
module.exports = function(grunt) {
// Load NPM Tasks
// https://github.com/shootaroo/jit-grunt
require('jit-grunt')(grunt);
grunt.loadNpmTasks('grunt-postcss');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// == Assemble YAML Front Matter
site: grunt.file.readYAML('_config.yml'),
meta: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n'
},
// == Assemble
assemble: {
options: {
flatten: true,
pkg: '<%= pkg %>',
site: '<%= site %>',
partials: '<%= site.includes %>/*.html',
layouts: '<%= site.layouts %>',
layoutext: '<%= site.layoutext %>',
layout: '<%= site.layout %>'
},
typeplate: {
files: {
'./': '<%= site.pages %>/*.html'
}
}
},
// == Grunt Dev Update
// https://npmjs.org/package/grunt-dev-update
// http://pgilad.github.io/grunt-dev-update
devUpdate: {
main: {
options: {
// Report updated dependencies? 'false' | 'true'
reportUpdated: false,
// 'force'|'report'|'prompt'
updateType : "force"
}
}
},
// == Watch Tasks
watch: {
html: {
files: ['templates/**/*.html'],
tasks : ['assemble']
},
sass: {
files: ['scss/**/*.scss'],
tasks: ['sass:dist', 'postcss']
},
css: {
files: ['css/**/*.css']
},
js: {
files: ['js/plugins.js','js/main.js']
},
livereload: {
options: {
livereload: true
},
files: ['templates/**/*.html', 'css/**/*.css', 'js/**/*js', '**/img/**/*.{png,jpg,jpeg,gif,webp,svg}']
}
},
// == Sass Config
sass: {
options: {
sourceMap: true
},
dist: {
files: {
'css/main.css' : 'scss/main.scss',
'css/demo.css' : 'scss/demo.scss'
}
}
},
// == PostCSS
// https://github.com/nDmitry/grunt-postcss
postcss: {
options: {
processors: [
require('autoprefixer')({
browsers: 'last 2 versions'
})
]
},
dist: {
src: 'css/main.css'
}
},
// == Run A Persistant Static Web Server
connect: {
server: {
options: {
port: 9001,
// '.' operates from the root of your Gruntfile.js.
// Otherwise you gotta do something like this...
// Users/user-name/www-directory/website-directory
// For me it's this...
// Users/grayghostvisuals/Sites/typeplate
base: '.',
keepalive: false, // set to false to work side by side w/watch task.
livereload: true,
open: true
}
}
},
// == Qunit Tests
qunit: {
all: ['*.html']
},
// == Concatenation
concat: {
options: {
banner: '<%= meta.banner %>',
separator: ';'
},
dist: {
src: [ 'js/plugins.js', 'js/main.js'],
dest: 'js/minified/main-min.js'
}
},
// == JSHint
jshint: {
files: ['Gruntfile.js', 'js/main.js'],
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true,
globals: {
jQuery: true,
require: true,
define: true,
requirejs: false,
describe: true,
expect: true,
it: true
}
},
uses_defaults: ['js/main.js']
},
// == Uglify/Minification
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
dist: {
src: ['js/minified/main-min.js'],
dest: 'js/minified/main-min.js'
}
},
copy: {
main: {
files: [
{
expand: true,
cwd: '',
src: ['bower_components/normalize-css/normalize.css'],
dest: 'css/'
}
]
},
pkg: {
files: [
{
expand: true,
cwd: '',
src: ['bower_components/typeplate/css/typeplate.css'],
dest: 'css/'
}
]
}
},
// == Asset Cache Bust
// https://github.com/gillesruppert/grunt-asset-cachebuster
// gived your assets a version flag ?v=1385933480172
asset_cachebuster: {
options: {
// Buster Also Accepts : Date.now()
buster: '1.1.2',
ignore: [
// Ignore cache busting CDN URIs
'//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
'js/bower_components/jquery.min.js',
'js/bower_components/modernizr.min.js'
]
},
build: {
files: [
{
src: ['index.html'],
dest: 'index.html'
}
]
}
}
});
// == Grunt Registered Tasks
grunt.registerTask('default', ['connect', 'watch']);
grunt.registerTask('update', ['devUpdate']);
grunt.registerTask('test', ['qunit']);
grunt.registerTask('hint', ['jshint']);
grunt.registerTask('glue', ['concat']);
grunt.registerTask('squish', ['uglify']);
grunt.registerTask('bust', ['asset_cachebuster']);
grunt.registerTask('build', ['copy', 'glue', 'squish', 'assemble']);
};