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 : { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 25 | 'lib': '../lib' |
Nils Diewald | c282619 | 2015-05-07 19:23:44 +0000 | [diff] [blame] | 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: { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 42 | files: [{ |
| 43 | expand: true, |
| 44 | cwd: 'dev/img/', |
| 45 | src: ['*.{png,gif,jpg}'], |
| 46 | dest: 'public/img/' |
| 47 | }] |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 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', |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 57 | 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss', |
Akron | b56986f | 2017-06-29 20:52:29 +0200 | [diff] [blame] | 58 | 'dev/css/kwic.css' : 'dev/scss/main/kwic.scss' |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 59 | } |
| 60 | } |
| 61 | }, |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 62 | jasmine: { |
| 63 | pivotal: { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 64 | src: [ |
| 65 | 'dev/js/src/menu.js', |
| 66 | 'dev/js/src/match.js', |
| 67 | 'dev/js/src/hint.js', |
| 68 | 'dev/js/src/vc.js' |
| 69 | ], |
| 70 | options: { |
| 71 | specs: 'dev/js/spec/*Spec.js', |
| 72 | vendor: ['dev/js/lib/require.js'] |
| 73 | } |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 74 | } |
| 75 | }, |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 76 | // see https://github.com/gruntjs/grunt-contrib-copy/issues/64 |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 77 | // for copying binary files |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 78 | copy : { |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 79 | options: { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 80 | process:false |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 81 | }, |
| 82 | main: { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 83 | files:[ |
| 84 | { |
| 85 | expand: true, |
| 86 | cwd: 'dev/font/', |
| 87 | src: '**', |
| 88 | dest: 'public/font/', |
| 89 | filter: 'isFile', |
| 90 | nonull: true, |
| 91 | timestamp: true |
| 92 | }, |
| 93 | { |
| 94 | expand: true, |
| 95 | cwd: 'dev/img/', |
| 96 | src: 'favicon.ico', |
| 97 | dest: 'public/', |
| 98 | filter: 'isFile', |
| 99 | nonull:true, |
| 100 | timestamp:true |
| 101 | }, |
| 102 | { |
| 103 | expand: true, |
| 104 | cwd: 'dev/img/', |
| 105 | src: '*.svg', |
| 106 | dest: 'public/img/', |
| 107 | filter: 'isFile', |
| 108 | nonull:true, |
| 109 | timestamp:true |
| 110 | } |
| 111 | ] |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 112 | } |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 113 | }, |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 114 | watch: { |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 115 | css: { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 116 | files: ['dev/scss/{util,base,fonts,kalamar,media}.scss', |
| 117 | 'dev/scss/footer/footer.scss', |
Akron | 189b359 | 2016-01-04 20:56:46 +0100 | [diff] [blame] | 118 | 'dev/scss/sidebar/sidebar.scss', |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 119 | 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss', |
Akron | b56986f | 2017-06-29 20:52:29 +0200 | [diff] [blame] | 120 | 'dev/scss/main/{alertify,koralquery,highlight,kwic,logos,tagger,' + |
Akron | 1517513 | 2017-09-07 18:12:55 +0200 | [diff] [blame^] | 121 | 'main,matchinfo,tree,pagination,query,'+ |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 122 | 'resultinfo,sidebar,tutorial}.scss' |
| 123 | ], |
| 124 | tasks: ['sass'], |
| 125 | options: { |
| 126 | spawn: false |
| 127 | } |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 128 | } |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 129 | } |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 130 | }); |
| 131 | |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 132 | grunt.loadNpmTasks('grunt-contrib-imagemin'); |
| 133 | grunt.loadNpmTasks('grunt-contrib-watch'); |
| 134 | grunt.loadNpmTasks('grunt-contrib-sass'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 135 | grunt.loadNpmTasks('grunt-contrib-jasmine'); |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 136 | grunt.loadNpmTasks('grunt-contrib-copy'); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 137 | grunt.loadNpmTasks('grunt-contrib-requirejs'); |
| 138 | |
| 139 | grunt.registerTask('default', ['requirejs']); |
Nils Diewald | a31a515 | 2015-04-17 21:05:23 +0000 | [diff] [blame] | 140 | grunt.registerTask('img', ['imagemin','copy']); |
Akron | 9f64fd0 | 2016-02-13 05:51:38 +0100 | [diff] [blame] | 141 | grunt.registerTask('js', ['requirejs']); |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 142 | grunt.registerTask('css', ['sass']); |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 143 | grunt.registerTask( |
| 144 | 'default', |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 145 | ['requirejs', 'imagemin', 'copy', 'sass'] |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 146 | ); |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 147 | }; |