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 |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 14 | * TODO: Implement a LaTeX generator for a pdf of the dokumentation |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 15 | */ |
Nils Diewald | c282619 | 2015-05-07 19:23:44 +0000 | [diff] [blame] | 16 | |
| 17 | // Generate requireJS files for l10n |
| 18 | var reqTasks = []; |
| 19 | for (var i in {'en' : 0, 'de' : 1}) { |
| 20 | reqTasks.push({ |
| 21 | options: { |
| 22 | // optimize: "uglify", |
| 23 | baseUrl: 'dev/js/src', |
| 24 | paths : { |
| 25 | 'lib': '../lib' |
| 26 | }, |
| 27 | wrap:true, |
| 28 | // dir : 'public/js', |
| 29 | name: 'lib/almond', |
| 30 | include : ['app/' + i], |
| 31 | out: 'public/js/kalamar-<%= pkg.version %>-' + i + '.js' |
| 32 | } |
| 33 | }) |
| 34 | }; |
| 35 | |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 36 | module.exports = function(grunt) { |
| 37 | grunt.initConfig({ |
| 38 | pkg: grunt.file.readJSON('package.json'), |
Nils Diewald | c282619 | 2015-05-07 19:23:44 +0000 | [diff] [blame] | 39 | requirejs: reqTasks, |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 40 | imagemin: { |
| 41 | dynamic: { |
| 42 | files: [{ |
| 43 | expand: true, |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 44 | cwd: 'dev/img/', |
Nils Diewald | 709f52f | 2015-05-21 18:32:58 +0000 | [diff] [blame^] | 45 | src: ['*.{png,gif,jpg}'], |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 46 | dest: 'public/img/' |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 47 | }] |
| 48 | } |
| 49 | }, |
| 50 | sass: { |
| 51 | dist: { |
| 52 | options: { |
| 53 | style: 'compressed' |
| 54 | }, |
| 55 | files: { |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 56 | 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss', |
| 57 | 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss' |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 58 | } |
| 59 | } |
| 60 | }, |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 61 | jasmine: { |
| 62 | pivotal: { |
| 63 | src: [ |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 64 | 'dev/js/src/menu.js', |
| 65 | 'dev/js/src/match.js', |
Nils Diewald | a122862 | 2015-04-25 01:59:10 +0000 | [diff] [blame] | 66 | 'dev/js/src/hint.js', |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 67 | 'dev/js/src/vc.js' |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 68 | ], |
| 69 | options: { |
Nils Diewald | a944fab | 2015-04-08 21:02:04 +0000 | [diff] [blame] | 70 | specs: 'dev/js/spec/*Spec.js' |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 71 | } |
| 72 | } |
| 73 | }, |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 74 | // see https://github.com/gruntjs/grunt-contrib-copy/issues/64 |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 75 | // for copying binary files |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 76 | copy : { |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 77 | options: { |
| 78 | process:false |
| 79 | }, |
| 80 | main: { |
| 81 | files:[ |
| 82 | { |
| 83 | expand: true, |
| 84 | cwd: 'dev/font/', |
| 85 | src: '**', |
| 86 | dest: 'public/font/', |
| 87 | filter: 'isFile', |
| 88 | nonull: true, |
| 89 | timestamp: true |
| 90 | }, |
| 91 | { |
Nils Diewald | 709f52f | 2015-05-21 18:32:58 +0000 | [diff] [blame^] | 92 | expand: false, |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 93 | cwd: 'dev/img/', |
| 94 | src: 'favicon.ico', |
| 95 | dest: 'public/', |
Nils Diewald | 709f52f | 2015-05-21 18:32:58 +0000 | [diff] [blame^] | 96 | filter: 'isFile', |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 97 | nonull:true, |
| 98 | timestamp:true |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 99 | }, |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 100 | { |
| 101 | expand: true, |
| 102 | cwd: 'dev/img/', |
Nils Diewald | 709f52f | 2015-05-21 18:32:58 +0000 | [diff] [blame^] | 103 | src: '*.svg', |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 104 | dest: 'public/img/', |
Nils Diewald | 709f52f | 2015-05-21 18:32:58 +0000 | [diff] [blame^] | 105 | filter: 'isFile', |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 106 | nonull:true, |
| 107 | timestamp:true |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 108 | } |
| 109 | ] |
| 110 | } |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 111 | }, |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 112 | watch: { |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 113 | css: { |
Nils Diewald | ab4d3ca | 2015-04-17 01:48:43 +0000 | [diff] [blame] | 114 | files: ['dev/scss/{util,base,fonts,kalamar,media}.scss', |
| 115 | 'dev/scss/footer/footer.scss', |
Nils Diewald | a122862 | 2015-04-25 01:59:10 +0000 | [diff] [blame] | 116 | 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss', |
Nils Diewald | 4c22125 | 2015-04-21 20:19:25 +0000 | [diff] [blame] | 117 | 'dev/scss/main/{alertify,highlight,kwic,logos,' + |
| 118 | 'main,matchinfo,pagination,query,'+ |
| 119 | 'resultinfo,sidebar,tutorial}.scss' |
Nils Diewald | ab4d3ca | 2015-04-17 01:48:43 +0000 | [diff] [blame] | 120 | ], |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 121 | tasks: ['sass'], |
| 122 | options: { |
| 123 | spawn: false |
| 124 | } |
| 125 | } |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 126 | } |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 127 | }); |
| 128 | |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 129 | grunt.loadNpmTasks('grunt-contrib-imagemin'); |
| 130 | grunt.loadNpmTasks('grunt-contrib-watch'); |
| 131 | grunt.loadNpmTasks('grunt-contrib-sass'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 132 | grunt.loadNpmTasks('grunt-contrib-jasmine'); |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 133 | grunt.loadNpmTasks('grunt-contrib-copy'); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 134 | grunt.loadNpmTasks('grunt-contrib-requirejs'); |
| 135 | |
| 136 | grunt.registerTask('default', ['requirejs']); |
Nils Diewald | a31a515 | 2015-04-17 21:05:23 +0000 | [diff] [blame] | 137 | grunt.registerTask('img', ['imagemin','copy']); |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 138 | grunt.registerTask('css', ['sass']); |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 139 | grunt.registerTask( |
| 140 | 'default', |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 141 | ['requirejs', 'imagemin', 'copy', 'sass'] |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 142 | ); |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 143 | }; |