UNPKG

16.6 kBJavaScriptView Raw
1module.exports = function(grunt) {
2
3 // configure the tasks
4 grunt.initConfig({
5 // Copy
6 copy: {
7 dist: { cwd: 'fonts', src: [ '**' ], dest: 'dist/fonts', expand: true },
8 },
9
10 // Jasmine
11 jasmine: {
12 components: {
13 src: [
14 'bin/materialize.js'
15 ],
16 options: {
17 vendor: [
18 'node_modules/jquery/dist/jquery.min.js',
19 'node_modules/jasmine-jquery/lib/jasmine-jquery.js'
20 ],
21 styles: 'bin/materialize.css',
22 specs: 'tests/spec/**/*Spec.js',
23 helpers: 'tests/spec/helper.js',
24 keepRunner : true,
25 //helpers: 'test/spec/*.js'
26 }
27 }
28 },
29
30
31
32 // Sass
33 sass: { // Task
34 expanded: { // Target
35 options: { // Target options
36 outputStyle: 'expanded',
37 sourcemap: false,
38 },
39 files: {
40 'dist/css/materialize.css': 'sass/materialize.scss',
41 }
42 },
43
44 min: {
45 options: {
46 outputStyle: 'compressed',
47 sourcemap: false
48 },
49 files: {
50 'dist/css/materialize.min.css': 'sass/materialize.scss',
51 }
52 },
53
54 // Compile ghpages css
55 gh: {
56 options: {
57 outputStyle: 'compressed',
58 sourcemap: false
59 },
60 files: {
61 'css/ghpages-materialize.css': 'sass/ghpages-materialize.scss',
62 }
63 },
64
65 // Compile bin css
66 bin: {
67 options: {
68 outputStyle: 'expanded',
69 sourcemap: false
70 },
71 files: {
72 'bin/materialize.css': 'sass/materialize.scss',
73 }
74 }
75 },
76
77 // PostCss Autoprefixer
78 postcss: {
79 options: {
80 processors: [
81 require('autoprefixer')({
82 browsers: [
83 'last 2 versions',
84 'Chrome >= 30',
85 'Firefox >= 30',
86 'ie >= 10',
87 'Safari >= 8']
88 })
89 ]
90 },
91 expended: {
92 src: 'dist/css/materialize.css'
93 },
94 min: {
95 src: 'dist/css/materialize.min.css'
96 },
97 gh: {
98 src: 'css/ghpages-materialize.css'
99 },
100 bin: {
101 src: 'bin/materialize.css'
102 }
103 },
104
105 // Browser Sync integration
106 browserSync: {
107 bsFiles: ["bin/*.js", "bin/*.css", "!**/node_modules/**/*"],
108 options: {
109 server: {
110 baseDir: "./" // make server from root dir
111 },
112 port: 8000,
113 ui: {
114 port: 8080,
115 weinre: {
116 port: 9090
117 }
118 },
119 open: false
120 }
121 },
122
123 // Concat
124 concat: {
125 options: {
126 separator: ';'
127 },
128 dist: {
129 // the files to concatenate
130 src: [
131 "js/initial.js",
132 "js/jquery.easing.1.3.js",
133 "js/animation.js",
134 "js/velocity.min.js",
135 "js/hammer.min.js",
136 "js/jquery.hammer.js",
137 "js/global.js",
138 "js/collapsible.js",
139 "js/dropdown.js",
140 "js/modal.js",
141 "js/materialbox.js",
142 "js/parallax.js",
143 "js/tabs.js",
144 "js/tooltip.js",
145 "js/waves.js",
146 "js/toasts.js",
147 "js/sideNav.js",
148 "js/scrollspy.js",
149 "js/forms.js",
150 "js/slider.js",
151 "js/cards.js",
152 "js/chips.js",
153 "js/pushpin.js",
154 "js/buttons.js",
155 "js/transitions.js",
156 "js/scrollFire.js",
157 "js/date_picker/picker.js",
158 "js/date_picker/picker.date.js",
159 "js/character_counter.js",
160 "js/carousel.js",
161 ],
162 // the location of the resulting JS file
163 dest: 'dist/js/materialize.js'
164 },
165 temp: {
166 // the files to concatenate
167 src: [
168 "js/initial.js",
169 "js/jquery.easing.1.3.js",
170 "js/animation.js",
171 "js/velocity.min.js",
172 "js/hammer.min.js",
173 "js/jquery.hammer.js",
174 "js/global.js",
175 "js/collapsible.js",
176 "js/dropdown.js",
177 "js/modal.js",
178 "js/materialbox.js",
179 "js/parallax.js",
180 "js/tabs.js",
181 "js/tooltip.js",
182 "js/waves.js",
183 "js/toasts.js",
184 "js/sideNav.js",
185 "js/scrollspy.js",
186 "js/forms.js",
187 "js/slider.js",
188 "js/cards.js",
189 "js/chips.js",
190 "js/pushpin.js",
191 "js/buttons.js",
192 "js/transitions.js",
193 "js/scrollFire.js",
194 "js/date_picker/picker.js",
195 "js/date_picker/picker.date.js",
196 "js/character_counter.js",
197 "js/carousel.js",
198 ],
199 // the location of the resulting JS file
200 dest: 'temp/js/materialize.js'
201 },
202 },
203
204 // Uglify
205 uglify: {
206 options: {
207 // Use these options when debugging
208 // mangle: false,
209 // compress: false,
210 // beautify: true
211
212 },
213 dist: {
214 files: {
215 'dist/js/materialize.min.js': ['dist/js/materialize.js']
216 }
217 },
218 bin: {
219 files: {
220 'bin/materialize.js': ['temp/js/materialize.js']
221 }
222 },
223 extras: {
224 files: {
225 'extras/noUiSlider/nouislider.min.js': ['extras/noUiSlider/nouislider.js']
226 }
227 }
228 },
229
230
231 // Compress
232 compress: {
233 main: {
234 options: {
235 archive: 'bin/materialize.zip',
236 level: 6
237 },
238 files:[
239 { expand: true, cwd: 'dist/', src: ['**/*'], dest: 'materialize/'},
240 { expand: true, cwd: './', src: ['LICENSE', 'README.md'], dest: 'materialize/'},
241 ]
242 },
243
244 src: {
245 options: {
246 archive: 'bin/materialize-src.zip',
247 level: 6
248 },
249 files:[
250 {expand: true, cwd: 'fonts/', src: ['**/*'], dest: 'materialize-src/fonts/'},
251 {expand: true, cwd: 'sass/', src: ['materialize.scss'], dest: 'materialize-src/sass/'},
252 {expand: true, cwd: 'sass/', src: ['components/**/*'], dest: 'materialize-src/sass/'},
253 {expand: true, cwd: 'js/', src: [
254 "initial.js",
255 "jquery.easing.1.3.js",
256 "animation.js",
257 "velocity.min.js",
258 "hammer.min.js",
259 "jquery.hammer.js",
260 "global.js",
261 "collapsible.js",
262 "dropdown.js",
263 "modal.js",
264 "materialbox.js",
265 "parallax.js",
266 "tabs.js",
267 "tooltip.js",
268 "waves.js",
269 "toasts.js",
270 "sideNav.js",
271 "scrollspy.js",
272 "forms.js",
273 "slider.js",
274 "cards.js",
275 "chips.js",
276 "pushpin.js",
277 "buttons.js",
278 "transitions.js",
279 "scrollFire.js",
280 "date_picker/picker.js",
281 "date_picker/picker.date.js",
282 "character_counter.js",
283 "carousel.js",
284 ], dest: 'materialize-src/js/'},
285 {expand: true, cwd: 'dist/js/', src: ['**/*'], dest: 'materialize-src/js/bin/'},
286 {expand: true, cwd: './', src: ['LICENSE', 'README.md'], dest: 'materialize-src/'}
287
288 ]
289 },
290
291 starter_template: {
292 options: {
293 archive: 'templates/starter-template.zip',
294 level: 6
295 },
296 files:[
297 { expand: true, cwd: 'dist/', src: ['**/*'], dest: 'starter-template/'},
298 { expand: true, cwd: 'templates/starter-template/', src: ['index.html', 'LICENSE'], dest: 'starter-template/'},
299 { expand: true, cwd: 'templates/starter-template/css', src: ['style.css'], dest: 'starter-template/css'},
300 { expand: true, cwd: 'templates/starter-template/js', src: ['init.js'], dest: 'starter-template/js'}
301
302 ]
303 },
304
305 parallax_template: {
306 options: {
307 archive: 'templates/parallax-template.zip',
308 level: 6
309 },
310 files:[
311 { expand: true, cwd: 'dist/', src: ['**/*'], dest: 'parallax-template/'},
312 { expand: true, cwd: 'templates/parallax-template/', src: ['index.html', 'LICENSE', 'background1.jpg', 'background2.jpg', 'background3.jpg'], dest: 'parallax-template/'},
313 { expand: true, cwd: 'templates/parallax-template/css', src: ['style.css'], dest: 'parallax-template/css'},
314 { expand: true, cwd: 'templates/parallax-template/js', src: ['init.js'], dest: 'parallax-template/js'}
315
316 ]
317 }
318
319 },
320
321
322 // Clean
323 clean: {
324 temp: {
325 src: [ 'temp/' ]
326 },
327 },
328
329 // Jade
330 jade: {
331 compile: {
332 options: {
333 pretty: true,
334 data: {
335 debug: false
336 }
337 },
338 files: {
339 "index.html": "jade/index.jade",
340 "icons.html": "jade/icons.jade",
341 "about.html": "jade/about.jade",
342 "sass.html": "jade/sass.jade",
343 "getting-started.html": "jade/getting-started.jade",
344 "mobile.html": "jade/mobile.jade",
345 "showcase.html": "jade/showcase.jade",
346 "parallax.html": "jade/parallax.jade",
347 "parallax-demo.html": "jade/parallax-demo.jade",
348 "typography.html": "jade/typography.jade",
349 "color.html": "jade/color.jade",
350 "shadow.html": "jade/shadow.jade",
351 "grid.html": "jade/grid.jade",
352 "media-css.html": "jade/media-css.jade",
353 "table.html": "jade/table.jade",
354 "helpers.html": "jade/helpers.jade",
355 "forms.html": "jade/forms.jade",
356 "buttons.html": "jade/buttons.jade",
357 "navbar.html": "jade/navbar.jade",
358 "cards.html": "jade/cards.jade",
359 "preloader.html": "jade/preloader.jade",
360 "collections.html": "jade/collections.jade",
361 "badges.html": "jade/badges.jade",
362 "footer.html": "jade/footer.jade",
363 "dialogs.html": "jade/dialogs.jade",
364 "modals.html": "jade/modals.jade",
365 "dropdown.html": "jade/dropdown.jade",
366 "tabs.html": "jade/tabs.jade",
367 "side-nav.html": "jade/sideNav.jade",
368 "pushpin.html": "jade/pushpin.jade",
369 "waves.html": "jade/waves.jade",
370 "media.html": "jade/media.jade",
371 "collapsible.html": "jade/collapsible.jade",
372 "chips.html": "jade/chips.jade",
373 "scrollfire.html": "jade/scrollFire.jade",
374 "scrollspy.html": "jade/scrollspy.jade",
375 "transitions.html": "jade/transitions.jade",
376 "fullscreen-slider-demo.html": "jade/fullscreen-slider-demo.jade",
377 "pagination.html": "jade/pagination.jade",
378 "breadcrumbs.html": "jade/breadcrumbs.jade",
379 "carousel.html": "jade/carousel.jade",
380 "pushpin-demo.html": "jade/pushpin-demo.jade",
381 "css-transitions.html": "jade/css-transitions.jade",
382 "404.html": "jade/404.jade",
383
384 }
385 }
386 },
387
388 // Watch Files
389 watch: {
390 jade: {
391 files: ['jade/**/*'],
392 tasks: ['jade_compile'],
393 options: {
394 interrupt: false,
395 spawn: false,
396 },
397 },
398
399 js: {
400 files: [ "js/**/*", "!js/init.js"],
401 tasks: ['js_compile'],
402 options: {
403 interrupt: false,
404 spawn: false,
405 },
406 },
407
408 sass: {
409 files: ['sass/**/*'],
410 tasks: ['sass_compile'],
411 options: {
412 interrupt: false,
413 spawn: false,
414 },
415 }
416 },
417
418
419 // Concurrent
420 concurrent: {
421 options: {
422 logConcurrentOutput: true,
423 limit: 10,
424 },
425 monitor: {
426 tasks: ["watch:jade", "watch:js", "watch:sass", "notify:watching", 'server']
427 },
428 },
429
430
431 // Notifications
432 notify: {
433 watching: {
434 options: {
435 enabled: true,
436 message: 'Watching Files!',
437 title: "Materialize", // defaults to the name in package.json, or will use project directory's name
438 success: true, // whether successful grunt executions should be notified automatically
439 duration: 1 // the duration of notification in seconds, for `notify-send only
440 }
441 },
442
443 sass_compile: {
444 options: {
445 enabled: true,
446 message: 'Sass Compiled!',
447 title: "Materialize",
448 success: true,
449 duration: 1
450 }
451 },
452
453 js_compile: {
454 options: {
455 enabled: true,
456 message: 'JS Compiled!',
457 title: "Materialize",
458 success: true,
459 duration: 1
460 }
461 },
462
463 jade_compile: {
464 options: {
465 enabled: true,
466 message: 'Jade Compiled!',
467 title: "Materialize",
468 success: true,
469 duration: 1
470 }
471 },
472
473 server: {
474 options: {
475 enabled: true,
476 message: 'Server Running!',
477 title: "Materialize",
478 success: true,
479 duration: 1
480 }
481 }
482 },
483
484 // Text Replace
485 replace: {
486 version: { // Does not edit README.md
487 src: [
488 'bower.json',
489 'package.json',
490 'package.js',
491 'jade/**/*.html'
492 ],
493 overwrite: true,
494 replacements: [{
495 from: grunt.option( "oldver" ),
496 to: grunt.option( "newver" )
497 }]
498 },
499 readme: { // Changes README.md
500 src: [
501 'README.md'
502 ],
503 overwrite: true,
504 replacements: [{
505 from: 'Current Version : v'+grunt.option( "oldver" ),
506 to: 'Current Version : v'+grunt.option( "newver" )
507 }]
508 },
509 },
510
511 // Create Version Header for files
512 usebanner: {
513 release: {
514 options: {
515 position: 'top',
516 banner: "/*!\n * Materialize v"+ grunt.option( "newver" ) +" (http://materializecss.com)\n * Copyright 2014-2015 Materialize\n * MIT License (https://raw.githubusercontent.com/Dogfalo/materialize/master/LICENSE)\n */",
517 linebreak: true
518 },
519 files: {
520 src: [ 'dist/css/*.css', 'dist/js/*.js']
521 }
522 }
523 },
524
525 // Rename files
526 rename: {
527 rename_src: {
528 src: 'bin/materialize-src'+'.zip',
529 dest: 'bin/materialize-src-v'+grunt.option( "newver" )+'.zip',
530 options: {
531 ignore: true
532 }
533 },
534 rename_compiled: {
535 src: 'bin/materialize'+'.zip',
536 dest: 'bin/materialize-v'+grunt.option( "newver" )+'.zip',
537 options: {
538 ignore: true
539 }
540 },
541 },
542
543 // Removes console logs
544 removelogging: {
545 source: {
546 src: ["js/**/*.js", "!js/velocity.min.js"],
547 options: {
548 // see below for options. this is optional.
549 }
550 }
551 },
552 });
553
554 // load the tasks
555 // grunt.loadNpmTasks('grunt-gitinfo');
556 grunt.loadNpmTasks('grunt-contrib-watch');
557 grunt.loadNpmTasks('grunt-contrib-copy');
558 grunt.loadNpmTasks('grunt-sass');
559 grunt.loadNpmTasks('grunt-contrib-concat');
560 grunt.loadNpmTasks('grunt-contrib-uglify');
561 grunt.loadNpmTasks('grunt-contrib-compress');
562 grunt.loadNpmTasks('grunt-contrib-clean');
563 grunt.loadNpmTasks('grunt-contrib-jade');
564 grunt.loadNpmTasks('grunt-concurrent');
565 grunt.loadNpmTasks('grunt-notify');
566 grunt.loadNpmTasks('grunt-text-replace');
567 grunt.loadNpmTasks('grunt-banner');
568 grunt.loadNpmTasks('grunt-rename');
569 grunt.loadNpmTasks('grunt-remove-logging');
570 grunt.loadNpmTasks('grunt-browser-sync');
571 grunt.loadNpmTasks('grunt-contrib-jasmine');
572 grunt.loadNpmTasks('grunt-postcss');
573 // define the tasks
574 grunt.registerTask(
575 'release',[
576 'lint',
577 'copy',
578 'sass:expanded',
579 'sass:min',
580 'postcss:expended',
581 'postcss:min',
582 'concat:dist',
583 'uglify:dist',
584 'uglify:extras',
585 'usebanner:release',
586 'compress:main',
587 'compress:src',
588 'compress:starter_template',
589 'compress:parallax_template',
590 'replace:version',
591 'replace:readme',
592 'rename:rename_src',
593 'rename:rename_compiled'
594 ]
595 );
596
597 grunt.registerTask('jade_compile', ['jade', 'notify:jade_compile']);
598 grunt.registerTask('js_compile', ['concat:temp', 'uglify:bin', 'notify:js_compile', 'clean:temp']);
599 grunt.registerTask('sass_compile', ['sass:gh', 'sass:bin', 'postcss:gh', 'postcss:bin', 'notify:sass_compile']);
600 grunt.registerTask('server', ['browserSync', 'notify:server']);
601 grunt.registerTask('lint', ['removelogging:source']);
602 grunt.registerTask('monitor', ["concurrent:monitor"]);
603 grunt.registerTask('travis', ['jasmine']);
604};