This repository has been archived by the owner on Sep 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Gruntfile.js
275 lines (268 loc) · 6.63 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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
// Generated on 2014-01-21 using generator-webapp 0.4.4
'use strict';
// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'
module.exports = function (grunt) {
// show elapsed time at the end
require('time-grunt')(grunt);
// load all grunt tasks
require('load-grunt-tasks')(grunt);
grunt.initConfig({
// configurable paths
yeoman: {
app: 'app',
dist: 'dist',
tmp: '.tmp'
},
watch: {
compass: {
files: ['<%= yeoman.app %>/**/*.{scss,sass}'],
tasks: ['compass']
},
copy: {
files: ['<%= yeoman.app %>/**/*.{js,css,html,svg,eot,ttf,woff}'],
tasks: ['copy:js_css_fonts_to_tmp']
},
coffee: {
files: ['<%= yeoman.app %>/**/*.coffee'],
tasks: ['coffee']
},
livereload: {
options: {
livereload: '<%= connect.options.livereload %>'
},
files: [
'<%= yeoman.app %>/**/*.html',
'.tmp/**/*.{js,css,html,svg}',
'<%= yeoman.app %>/**/images/{,*/}*.{gif,jpeg,jpg,png,svg,webp}'
]
}
},
connect: {
options: {
port: 9000,
livereload: 35728,
// change this to '0.0.0.0' to access the server from outside
hostname: 'localhost'
},
livereload: {
options: {
open: true,
base: [
'.tmp',
'<%= yeoman.app %>'
]
}
},
test: {
options: {
base: [
'.tmp',
'test',
'<%= yeoman.app %>'
]
}
},
dist: {
options: {
open: true,
base: '<%= yeoman.dist %>',
livereload: false
}
}
},
clean: {
default: {
files: [{
dot: true,
src: [
'.tmp',
'<%= yeoman.dist %>/*',
'!<%= yeoman.dist %>/.git*'
]
}]
}
},
coffee: {
default: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/coffee',
src: '**/*.coffee',
dest: '<%= yeoman.tmp %>/js',
ext: '.js'
}]
}
},
compass: {
options: {
sassDir: '<%= yeoman.app %>/scss',
cssDir: '<%= yeoman.tmp %>/css',
generatedImagesDir: '.tmp/images/generated',
imagesDir: '<%= yeoman.app %>/images',
javascriptsDir: '<%= yeoman.app %>/scripts',
fontsDir: '<%= yeoman.app %>/styles/fonts',
importPath: '<%= yeoman.app %>',
httpImagesPath: '/images',
httpGeneratedImagesPath: '/images/generated',
httpFontsPath: '/styles/fonts',
relativeAssets: false,
assetCacheBuster: false
},
default: {
options: {
}
}
},
// not used since Uglify task does concat,
// but still available if needed
/*concat: {
dist: {}
},*/
// not enabled since usemin task does concat and uglify
// check index.html to edit your build targets
// enable this task if you prefer defining your build targets here
/*uglify: {
dist: {}
},*/
rev: {
dist: {
files: {
src: [
'<%= yeoman.dist %>/{,*/}*.js',
'<%= yeoman.dist %>/{,*/}*.css',
'<%= yeoman.dist %>/{,*/}/images/*.{gif,jpeg,jpg,png,webp}',
'<%= yeoman.dist %>/fonts/{,*/}*.*'
]
}
}
},
useminPrepare: {
options: {
dest: '<%= yeoman.dist %>'
},
html: '<%= yeoman.app %>/**/index.html'
},
usemin: {
options: {
assetsDirs: ['<%= yeoman.dist %>']
},
html: ['<%= yeoman.dist %>/{,*/}*.html'],
css: ['<%= yeoman.dist %>/{,*/}*.css']
},
imagemin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}images/*.{gif,jpeg,jpg,png}',
dest: '<%= yeoman.dist %>/images'
}]
}
},
svgmin: {
dist: {
files: [{
expand: true,
cwd: '<%= yeoman.app %>/images',
src: '{,*/}*.svg',
dest: '<%= yeoman.dist %>/images'
}]
}
},
cssmin: {
// This task is pre-configured if you do not wish to use Usemin
// blocks for your CSS. By default, the Usemin block from your
// `index.html` will take care of minification, e.g.
//
// <!-- build:css({.tmp,app}) styles/main.css -->
//
// dist: {
// files: {
// '<%= yeoman.dist %>/styles/main.css': [
// '.tmp/styles/{,*/}*.css',
// '<%= yeoman.app %>/styles/{,*/}*.css'
// ]
// }
// }
},
htmlmin: {
dist: {
options: {
/*removeCommentsFromCDATA: true,
// https://github.com/yeoman/grunt-usemin/issues/44
//collapseWhitespace: true,
collapseBooleanAttributes: true,
removeAttributeQuotes: true,
removeRedundantAttributes: true,
useShortDoctype: true,
removeEmptyAttributes: true,
removeOptionalTags: true*/
},
files: [{
expand: true,
cwd: '<%= yeoman.app %>',
src: '*.html',
dest: '<%= yeoman.dist %>'
}]
}
},
// Put files not handled in other tasks here
copy: {
js_css_fonts_to_tmp: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.app %>',
dest: '<%= yeoman.tmp %>',
src: [
'**/*.{js,css,html,svg,eot,ttf,woff}'
]
}]
},
html_fonts_to_dist: {
files: [{
expand: true,
dot: true,
cwd: '<%= yeoman.tmp %>',
dest: '<%= yeoman.dist %>',
src: [
'**/*.{html,svg,ttf,eot,woff}'
]
}]
}
}
});
grunt.registerTask('serve', function (target) {
if (target === 'dist') {
return grunt.task.run(['build', 'connect:dist:keepalive']);
}
grunt.task.run([
'clean',
'copy:js_css_fonts_to_tmp',
'compass',
'coffee',
'connect:livereload',
'watch'
]);
});
grunt.registerTask('build', [
'clean',
'copy:js_css_fonts_to_tmp',
'compass',
'coffee',
'useminPrepare',
'concat',
'cssmin',
'uglify',
'copy:html_fonts_to_dist',
'usemin'
]);
grunt.registerTask('default', [
'serve'
]);
};