Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 1 | /** |
| 2 | * Grunt build file for Kalamar. |
| 3 | * Create assets (based on files in /dev) running |
| 4 | * $ grunt |
| 5 | * in the current folder. |
| 6 | * |
| 7 | * @author Nils Diewald |
| 8 | */ |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 9 | /* |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 10 | * TODO: Use https://www.npmjs.com/package/grunt-contrib-compress |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 11 | * for assets. |
| 12 | * http://yui.github.io/yuidoc/ |
| 13 | * TODO: Use https://www.npmjs.com/package/grunt-contrib-yuidoc |
| 14 | * TODO: Use RequireJS |
| 15 | * http://addyosmani.com/writing-modular-js/ |
| 16 | * http://qnundrum.com/question/393866 |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 17 | */ |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 18 | module.exports = function(grunt) { |
| 19 | grunt.initConfig({ |
| 20 | pkg: grunt.file.readJSON('package.json'), |
| 21 | concat: { |
| 22 | dist: { |
| 23 | src : [ |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 24 | 'dev/js/lib/dagre/dagre.min.js', |
| 25 | 'dev/js/src/menu.js', |
| 26 | 'dev/js/src/match.js', |
| 27 | 'dev/js/src/hint.js', |
| 28 | 'dev/js/src/vc.js', |
| 29 | 'dev/js/src/api.js', |
| 30 | 'dev/js/src/session.js', |
| 31 | 'dev/js/src/tutorial.js', |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 32 | 'dev/js/src/init.js' |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 33 | ], |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 34 | dest: 'dev/js/build/kalamar.js' |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 35 | } |
| 36 | }, |
| 37 | uglify : { |
| 38 | build : { |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 39 | src: 'dev/js/build/kalamar.js', |
| 40 | dest: 'public/js/kalamar-<%= pkg.version %>.js' |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 41 | } |
| 42 | }, |
| 43 | imagemin: { |
| 44 | dynamic: { |
| 45 | files: [{ |
| 46 | expand: true, |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 47 | cwd: 'dev/img/', |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 48 | src: ['*.{png,gif,jpg,svg}'], |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 49 | dest: 'public/img/' |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 50 | }] |
| 51 | } |
| 52 | }, |
| 53 | sass: { |
| 54 | dist: { |
| 55 | options: { |
| 56 | style: 'compressed' |
| 57 | }, |
| 58 | files: { |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 59 | 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss', |
| 60 | 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss' |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 61 | } |
| 62 | } |
| 63 | }, |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 64 | jasmine: { |
| 65 | pivotal: { |
| 66 | src: [ |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 67 | 'dev/js/src/menu.js', |
| 68 | 'dev/js/src/match.js', |
| 69 | 'dev/js/src/match.js', |
| 70 | 'dev/js/src/vc.js' |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 71 | ], |
| 72 | options: { |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 73 | specs: 'dev/js/spec/*Spec.js' |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 74 | } |
| 75 | } |
| 76 | }, |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 77 | // see https://github.com/gruntjs/grunt-contrib-copy/issues/64 |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 78 | // for copying binary files |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 79 | copy : { |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 80 | options: { |
| 81 | process:false |
| 82 | }, |
| 83 | main: { |
| 84 | files:[ |
| 85 | { |
| 86 | expand: true, |
| 87 | cwd: 'dev/font/', |
| 88 | src: '**', |
| 89 | dest: 'public/font/', |
| 90 | filter: 'isFile', |
| 91 | nonull: true, |
| 92 | timestamp: true |
| 93 | }, |
| 94 | { |
| 95 | expand: true, |
| 96 | cwd: 'dev/img/', |
| 97 | src: 'favicon.ico', |
| 98 | dest: 'public/', |
| 99 | nonull:true, |
| 100 | timestamp:true |
| 101 | } |
| 102 | ] |
| 103 | } |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 104 | }, |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 105 | watch: { |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 106 | css: { |
Nils Diewald | 1c54692 | 2015-04-13 01:56:19 +0000 | [diff] [blame^] | 107 | files: ['dev/scss/{util,fonts,base,header,searchbar,matchinfo,resultinfo,kwic,menu,hint,pagination,logos,alertify,vc,media,kalamar,tutorial,query,sidebar,footer}.scss'], |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 108 | tasks: ['sass'], |
| 109 | options: { |
| 110 | spawn: false |
| 111 | } |
| 112 | } |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 113 | } |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 114 | }); |
| 115 | |
| 116 | grunt.loadNpmTasks('grunt-contrib-concat'); |
| 117 | grunt.loadNpmTasks('grunt-contrib-uglify'); |
| 118 | grunt.loadNpmTasks('grunt-contrib-imagemin'); |
| 119 | grunt.loadNpmTasks('grunt-contrib-watch'); |
| 120 | grunt.loadNpmTasks('grunt-contrib-sass'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 121 | grunt.loadNpmTasks('grunt-contrib-jasmine'); |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 122 | grunt.loadNpmTasks('grunt-contrib-copy'); |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 123 | grunt.registerTask('css', ['sass']); |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 124 | grunt.registerTask( |
| 125 | 'default', |
| 126 | ['copy', 'concat', 'uglify', 'imagemin', 'sass'] |
| 127 | ); |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 128 | }; |