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