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