-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
422 lines (349 loc) · 13 KB
/
Copy pathGruntfile.js
File metadata and controls
422 lines (349 loc) · 13 KB
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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
module.exports = function(grunt) {
'use strict';
grunt.initConfig({
// Metadata.
meta: {
basePath: '../',
srcPath: '../src/',
deployPath: '../deploy/',
root: '/Users/Leo/Documents/root/angular-base',
www: '/Users/Leo/Documents/root/angular-base/www',
jasmine: '<%= meta.root %>/tests/'
},
/* node webserver using express */
express: {
options: {
// Override defaults here
},
web: {
options: {
script: '<%= meta.root %>/scripts/server.js'
}
}
},
// Compiles SASS (with Compass) into CSS.
compass: { // Task
dist: { // Target
options: { // Target options
sassDir: 'sass',
cssDir: 'css',
environment: 'production',
outputStyle: 'compact'
},
files: {
'<%= meta.root %>/app/css/main.css' : '<%= meta.root %>/scss/main.scss'
}
}
},
// Compiles SASS into CSS.
// generates the source-map
sass: {
dist: { // Target
options: {
style: 'expanded',
debugInfo: false,
sourcemap: false
},
files: {
'<%= meta.root %>/app/css/main.css' : '<%= meta.root %>/scss/main.scss',
'<%= meta.root %>/app/css/bs.css' : '<%= meta.root %>/bower_components/bootstrap-sass-official/vendor/assets/stylesheets/bootstrap.scss'
}
}
},
// Lints compiled CSS files for errors or bad practice: https://github.com/CSSLint/csslint/wiki/Rules
csslint: {
options: {
'adjoining-classes': false,
'box-model': true,
'box-sizing': false,
'bulletproof-font-face': 2,
'display-property-grouping': true,
'duplicate-background-images': true,
'duplicate-properties': true,
'empty-rules': 2,
'fallback-colors': true,
'import': 2,
'important': true,
'known-properties': 2,
'overqualified-elements': true,
'unqualified-attributes': 2,
'underscore-property-hack': 2
},
src: ['app/css/*.css']
},
// Concatenates and minifys the following tasks.
uglify: {
options: {
banner: '',
beautify: true,
preserveComments: false
},
dist: {
src: [
/*
'js/libs/handlebars.js',
'js/libs/swfobject.js',
'js/src/Player.js',
*/
'app/js/src/main.js'
],
dest: 'app/js/build.min.js'
}
},
requirejs: {
compile: {
options: {
baseUrl: "path/to/base",
mainConfigFile: "path/to/config.js",
name: "path/to/almond", // assumes a production build using almond
out: "path/to/optimized.js"
}
}
},
jshint: {
options: {
// Specifying JSHint options and globals
jshintrc: '.jshintrc'
},
files: ['Gruntfile.js', './js/lib/*.js'] // libext are not under jshint
},
connect: {
test : {
port : 8888
}
},
jasmine: {
simple: {
src: '<%= meta.jasmine %>/src/**/*.js',
options: {
specs: '<%= meta.jasmine %>spec/**/*Spec.js',
helpers: '<%= meta.jasmine %>lib/helpers/*.js'
}
},
templateTest: {
// project's source files
src: '<%= meta.jasmine %>/src/**/*.js',
options: {
// Jasmine spec files
specs: '<%= meta.jasmine %>spec/*Spec.js',
// spec helper files
helpers: '<%= jasmine %>lib/helpers/*.js',
host: 'http://192.168.0.5:8888/',
template: require('grunt-template-jasmine-requirejs'),
templateOptions: {
requireConfigFile: '<%= meta.root %>/app/js/main.js',
requireConfig: {
baseUrl: 'overridden/baseUrl'
}
}
}
}
},
// The responsive_images task will take your source image and
// create images at different resolutions for use
// needs: GraphicsMagick or ImageMagick
// brew install GraphicsMagick
// or
// brew install ImageMagick
responsive_images: {
myTask: {
options: {
sizes: [{
name: "small",
width: 320
},{
name: 'medium',
width: 640
},{
name: 'large',
width: 1024
}]
},
files: [{
expand: true,
src: ['<%= meta.root %>/img/source/**.{jpg,gif,png}'],
cwd: '',
custom_dest: 'img/size/{%= width %}/'
}]
}
},
uncss: {
dist: {
options: {
ignoreSheets : [/fonts.googleapis/]
},
files: {
// HTML files you would like scanned
'css/main.css': ['./index.html']
}
}
},
ngmin: {
controllers: {
src: ['test/src/controllers/one.js'],
dest: 'test/generated/controllers/one.js'
},
directives: {
expand: true,
cwd: 'test/src',
src: ['directives/**/*.js'],
dest: 'test/generated'
}
},
// problems?
// ps aux | grep karma
// kill -9 iD
karma: {
unit: {
configFile: 'karma.conf.js',
background: true
}
},
// grunt-modernizr automatically find references to Modernizr detects in your code
modernizr: {
dist: {
// [REQUIRED] Path to the build you're using for development.
"devFile" : "<%= meta.root %>/bower_components/modernizr/modernizr.js",
// [REQUIRED] Path to save out the built file.
"outputFile" : "<%= meta.root %>/bower_components/modernizr/modernizr-custom.js",
// Based on default settings on http://modernizr.com/download/
"extra" : {
"shiv" : true,
"printshiv" : false,
"load" : true,
"mq" : true,
"cssclasses" : true,
"fontface" : true
},
// Based on default settings on http://modernizr.com/download/
"extensibility" : {
"addtest" : false,
"prefixed" : false,
"teststyles" : false,
"testprops" : false,
"testallprops" : false,
"hasevents" : false,
"prefixes" : false,
"domprefixes" : false
},
// By default, source is uglified before saving
"uglify" : true,
// Define any tests you want to implicitly include.
"tests" : [],
// By default, this task will crawl your project for references to Modernizr tests.
// Set to false to disable.
"parseFiles" : true,
// When parseFiles = true, this task will crawl all *.js, *.css, *.scss files, except files that are in node_modules/.
// You can override this by defining a "files" array below.
// "files" : {
// "src": []
// },
// When parseFiles = true, matchCommunityTests = true will attempt to
// match user-contributed tests.
"matchCommunityTests" : false,
// Have custom Modernizr tests? Add paths to their location here.
"customTests" : []
}
},
// watching tasks
watch: {
files: [
'<%= meta.root %>/app/js/**/*.js',
'<%= meta.root %>/scss/**/*.scss',
'<%= meta.root %>/app/partials/**/*.scss',
'<%= meta.root %>/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
],
/* testing livereload */
frontend: {
options: {
livereload: true
},
files: [
'<%= meta.root %>/app/js/**/*.js',
'<%= meta.root %>/scss/**/*.scss',
'<%= meta.root %>/app/partials/**/*.scss',
'<%= meta.root %>/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
},
connect: {
options: {
spawn: false,
port: 9000,
livereload: 35728,
// change this to '0.0.0.0' to access the server from outside
hostname: "127.0.0.1"
},
livereload: {
options: {
open: {
target: 'http://localhost:9000/'
},
base: [
'<%= meta.root %>'
]
}
},
files: [
'<%= meta.root %>/app/js/**/*.js',
'<%= meta.root %>/scss/**/*.scss',
'<%= meta.root %>/app/partials/**/*.scss',
'<%= meta.root %>/img/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
]
},
// run unit tests with karma (server needs to be already running)
karma: {
files: ['app/js/**/*.js', 'test/browser/**/*.js'],
tasks: ['karma:unit'] //NOTE the :run flag
},
// Watch for sass changes, building CSS directly
css: {
// Which files to watch (all .scss files recursively in the scss directory)
files: [
'<%= meta.root %>/scss/*.scss'
],
tasks: ['sass:dist'],
options: {
nospawn: true
}
},
// Watch for JS changes, linting the JS and copying direct to deployment directory.
scripts: {
files: ['Gruntfile.js', 'server.js', '<%= meta.root %>/js/lib/*.js', '<%= meta.www %>/tests/**/*.js'],
tasks: ['jshint', 'uglify:dist'],
options: {
//spawn: false,
livereload: true
}
},
// Watch for SASS changes, building CSS directly into deployment directory.
sass: {
files: ['<%= meta.root %>/scss/**/*.scss'],
tasks: ['compass:dist']
}
}
});
// // Register tasks.
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-compass');
grunt.loadNpmTasks('grunt-contrib-csslint');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-ngmin'); // add the [] for production uglify
grunt.loadNpmTasks('grunt-karma');
grunt.loadNpmTasks("grunt-modernizr");
grunt.loadNpmTasks('grunt-express-server');
grunt.loadNpmTasks('grunt-parallel');
grunt.loadNpmTasks('grunt-contrib-connect');
// Task definitions: put the tasks on a factory
grunt.registerTask('default', [
'watch', 'jshint', 'compass', 'csslint', 'uglify', 'requirejs' ]);
grunt.registerTask('test', [
'karma', 'uglify'
]);
grunt.registerTask('serve', [
'connect', 'watch'
]);
};