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