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