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 | |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 17 | module.exports = function(grunt) { |
Akron | e91da78 | 2017-12-15 17:17:50 +0100 | [diff] [blame^] | 18 | |
| 19 | var config; |
| 20 | |
| 21 | try { |
| 22 | config = grunt.file.readJSON('kalamar.conf.json'); |
| 23 | } |
| 24 | catch(err) { |
| 25 | console.log("Error: " + err); |
| 26 | config = {}; |
| 27 | }; |
| 28 | |
| 29 | if (config["include"] === undefined) { |
| 30 | config["include"] = [ |
| 31 | 'hint/foundries/base', |
| 32 | 'hint/foundries/dereko' |
| 33 | ]; |
| 34 | }; |
| 35 | |
| 36 | // Generate requireJS files for l10n |
| 37 | var reqTasks = []; |
| 38 | for (var i in {'en' : 0, 'de' : 1}) { |
| 39 | |
| 40 | var includeFiles = config["include"].slice(); |
| 41 | includeFiles.push('app/' + i); |
| 42 | |
| 43 | reqTasks.push({ |
| 44 | options: { |
| 45 | // optimize: "uglify", |
| 46 | baseUrl: 'dev/js/src', |
| 47 | paths : { |
| 48 | 'lib': '../lib' |
| 49 | }, |
| 50 | wrap:true, |
| 51 | // dir : 'public/js', |
| 52 | name: 'lib/almond', |
| 53 | include : includeFiles, |
| 54 | out: 'public/js/kalamar-<%= pkg.version %>-' + i + '.js' |
| 55 | } |
| 56 | }) |
| 57 | }; |
| 58 | |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 59 | grunt.initConfig({ |
| 60 | pkg: grunt.file.readJSON('package.json'), |
Nils Diewald | c282619 | 2015-05-07 19:23:44 +0000 | [diff] [blame] | 61 | requirejs: reqTasks, |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 62 | imagemin: { |
| 63 | dynamic: { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 64 | files: [{ |
| 65 | expand: true, |
| 66 | cwd: 'dev/img/', |
| 67 | src: ['*.{png,gif,jpg}'], |
| 68 | dest: 'public/img/' |
| 69 | }] |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 70 | } |
| 71 | }, |
| 72 | sass: { |
| 73 | dist: { |
| 74 | options: { |
| 75 | style: 'compressed' |
| 76 | }, |
| 77 | files: { |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 78 | 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss', |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 79 | 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss', |
Akron | b56986f | 2017-06-29 20:52:29 +0200 | [diff] [blame] | 80 | 'dev/css/kwic.css' : 'dev/scss/main/kwic.scss' |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 81 | } |
| 82 | } |
| 83 | }, |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 84 | jasmine: { |
| 85 | pivotal: { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 86 | src: [ |
| 87 | 'dev/js/src/menu.js', |
| 88 | 'dev/js/src/match.js', |
| 89 | 'dev/js/src/hint.js', |
| 90 | 'dev/js/src/vc.js' |
| 91 | ], |
| 92 | options: { |
| 93 | specs: 'dev/js/spec/*Spec.js', |
| 94 | vendor: ['dev/js/lib/require.js'] |
| 95 | } |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 96 | } |
| 97 | }, |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 98 | // see https://github.com/gruntjs/grunt-contrib-copy/issues/64 |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 99 | // for copying binary files |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 100 | copy : { |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 101 | options: { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 102 | process:false |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 103 | }, |
| 104 | main: { |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 105 | files:[ |
| 106 | { |
| 107 | expand: true, |
| 108 | cwd: 'dev/font/', |
| 109 | src: '**', |
| 110 | dest: 'public/font/', |
| 111 | filter: 'isFile', |
| 112 | nonull: true, |
| 113 | timestamp: true |
| 114 | }, |
| 115 | { |
| 116 | expand: true, |
| 117 | cwd: 'dev/img/', |
| 118 | src: 'favicon.ico', |
| 119 | dest: 'public/', |
| 120 | filter: 'isFile', |
| 121 | nonull:true, |
| 122 | timestamp:true |
| 123 | }, |
| 124 | { |
| 125 | expand: true, |
| 126 | cwd: 'dev/img/', |
| 127 | src: '*.svg', |
| 128 | dest: 'public/img/', |
| 129 | filter: 'isFile', |
| 130 | nonull:true, |
| 131 | timestamp:true |
| 132 | } |
| 133 | ] |
Nils Diewald | aa17d14 | 2015-04-08 23:32:23 +0000 | [diff] [blame] | 134 | } |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 135 | }, |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 136 | watch: { |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 137 | css: { |
Akron | ae8f31c | 2017-11-28 18:05:52 +0100 | [diff] [blame] | 138 | files: ['dev/scss/{util,base,fonts,kalamar,media,no-js}.scss', |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 139 | 'dev/scss/footer/footer.scss', |
Akron | 189b359 | 2016-01-04 20:56:46 +0100 | [diff] [blame] | 140 | 'dev/scss/sidebar/sidebar.scss', |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 141 | 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss', |
Akron | bd39a43 | 2017-09-20 13:57:13 +0200 | [diff] [blame] | 142 | 'dev/scss/main/{alertify,intro,koralquery,highlight,kwic,logos,tagger,' + |
Akron | 1517513 | 2017-09-07 18:12:55 +0200 | [diff] [blame] | 143 | 'main,matchinfo,tree,pagination,query,'+ |
Akron | 49bfdbf | 2016-11-22 21:47:33 +0100 | [diff] [blame] | 144 | 'resultinfo,sidebar,tutorial}.scss' |
| 145 | ], |
| 146 | tasks: ['sass'], |
| 147 | options: { |
| 148 | spawn: false |
| 149 | } |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 150 | } |
Nils Diewald | 2488d05 | 2015-04-09 21:46:02 +0000 | [diff] [blame] | 151 | } |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 152 | }); |
| 153 | |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 154 | grunt.loadNpmTasks('grunt-contrib-imagemin'); |
| 155 | grunt.loadNpmTasks('grunt-contrib-watch'); |
| 156 | grunt.loadNpmTasks('grunt-contrib-sass'); |
Nils Diewald | a297f06 | 2015-04-02 00:23:46 +0000 | [diff] [blame] | 157 | grunt.loadNpmTasks('grunt-contrib-jasmine'); |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 158 | grunt.loadNpmTasks('grunt-contrib-copy'); |
Nils Diewald | 0e6992a | 2015-04-14 20:13:52 +0000 | [diff] [blame] | 159 | grunt.loadNpmTasks('grunt-contrib-requirejs'); |
| 160 | |
| 161 | grunt.registerTask('default', ['requirejs']); |
Nils Diewald | a31a515 | 2015-04-17 21:05:23 +0000 | [diff] [blame] | 162 | grunt.registerTask('img', ['imagemin','copy']); |
Akron | 9f64fd0 | 2016-02-13 05:51:38 +0100 | [diff] [blame] | 163 | grunt.registerTask('js', ['requirejs']); |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 164 | grunt.registerTask('css', ['sass']); |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 165 | grunt.registerTask( |
| 166 | 'default', |
Nils Diewald | fccfbcb | 2015-04-29 20:48:19 +0000 | [diff] [blame] | 167 | ['requirejs', 'imagemin', 'copy', 'sass'] |
Nils Diewald | ce32811 | 2015-04-08 22:48:18 +0000 | [diff] [blame] | 168 | ); |
Nils Diewald | ea23674 | 2015-03-26 21:55:36 +0000 | [diff] [blame] | 169 | }; |