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