blob: d949a9021b3a72b329901970a869748c562628f7 [file] [log] [blame]
Nils Diewald2488d052015-04-09 21:46:02 +00001/**
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 Diewaldea236742015-03-26 21:55:36 +00009/*
Nils Diewaldea236742015-03-26 21:55:36 +000010 * TODO: Use https://www.npmjs.com/package/grunt-contrib-compress
Nils Diewald2488d052015-04-09 21:46:02 +000011 * for assets.
12 * http://yui.github.io/yuidoc/
13 * TODO: Use https://www.npmjs.com/package/grunt-contrib-yuidoc
Nils Diewald4c221252015-04-21 20:19:25 +000014 * TODO: Implement a LaTeX generator for a pdf of the dokumentation
Nils Diewaldea236742015-03-26 21:55:36 +000015 */
Nils Diewaldea236742015-03-26 21:55:36 +000016module.exports = function(grunt) {
17 grunt.initConfig({
18 pkg: grunt.file.readJSON('package.json'),
Nils Diewald0e6992a2015-04-14 20:13:52 +000019 requirejs: {
20 compile: {
21 options: {
22 // optimize: "uglify",
23 baseUrl: 'dev/js/src',
24 paths : {
25 'lib': '../lib'
26 },
27 wrap:true,
Nils Diewald7c8ced22015-04-15 19:21:00 +000028 include : ['app'],
29 insertRequire: ['app'],
Nils Diewald0e6992a2015-04-14 20:13:52 +000030 name: 'lib/almond',
31 out: 'public/js/kalamar-<%= pkg.version %>.js'
32 }
33 }
34 },
Nils Diewaldea236742015-03-26 21:55:36 +000035 imagemin: {
36 dynamic: {
37 files: [{
38 expand: true,
Nils Diewalda944fab2015-04-08 21:02:04 +000039 cwd: 'dev/img/',
Nils Diewalda297f062015-04-02 00:23:46 +000040 src: ['*.{png,gif,jpg,svg}'],
Nils Diewalda944fab2015-04-08 21:02:04 +000041 dest: 'public/img/'
Nils Diewaldea236742015-03-26 21:55:36 +000042 }]
43 }
44 },
45 sass: {
46 dist: {
47 options: {
48 style: 'compressed'
49 },
50 files: {
Nils Diewaldce328112015-04-08 22:48:18 +000051 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss',
52 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000053 }
54 }
55 },
Nils Diewalda297f062015-04-02 00:23:46 +000056 jasmine: {
57 pivotal: {
58 src: [
Nils Diewalda944fab2015-04-08 21:02:04 +000059 'dev/js/src/menu.js',
60 'dev/js/src/match.js',
Nils Diewalda1228622015-04-25 01:59:10 +000061 'dev/js/src/hint.js',
Nils Diewalda944fab2015-04-08 21:02:04 +000062 'dev/js/src/vc.js'
Nils Diewalda297f062015-04-02 00:23:46 +000063 ],
64 options: {
Nils Diewalda944fab2015-04-08 21:02:04 +000065 specs: 'dev/js/spec/*Spec.js'
Nils Diewalda297f062015-04-02 00:23:46 +000066 }
67 }
68 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000069 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000070 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000071 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000072 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
Nils Diewaldfccfbcb2015-04-29 20:48:19 +000093 },
94 // Needs to overwrite the prepared svg as it corrupts the embedded js
95 {
96 expand: true,
97 cwd: 'dev/img/',
98 src: 'korap-overview.svg',
99 dest: 'public/img/',
100 nonull:true,
101 timestamp:true
Nils Diewaldaa17d142015-04-08 23:32:23 +0000102 }
103 ]
104 }
Nils Diewaldce328112015-04-08 22:48:18 +0000105 },
Nils Diewaldea236742015-03-26 21:55:36 +0000106 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000107 css: {
Nils Diewaldab4d3ca2015-04-17 01:48:43 +0000108 files: ['dev/scss/{util,base,fonts,kalamar,media}.scss',
109 'dev/scss/footer/footer.scss',
Nils Diewalda1228622015-04-25 01:59:10 +0000110 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss',
Nils Diewald4c221252015-04-21 20:19:25 +0000111 'dev/scss/main/{alertify,highlight,kwic,logos,' +
112 'main,matchinfo,pagination,query,'+
113 'resultinfo,sidebar,tutorial}.scss'
Nils Diewaldab4d3ca2015-04-17 01:48:43 +0000114 ],
Nils Diewaldea236742015-03-26 21:55:36 +0000115 tasks: ['sass'],
116 options: {
117 spawn: false
118 }
119 }
Nils Diewald2488d052015-04-09 21:46:02 +0000120 }
Nils Diewaldea236742015-03-26 21:55:36 +0000121 });
122
Nils Diewaldea236742015-03-26 21:55:36 +0000123 grunt.loadNpmTasks('grunt-contrib-imagemin');
124 grunt.loadNpmTasks('grunt-contrib-watch');
125 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000126 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000127 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000128 grunt.loadNpmTasks('grunt-contrib-requirejs');
129
130 grunt.registerTask('default', ['requirejs']);
Nils Diewalda31a5152015-04-17 21:05:23 +0000131 grunt.registerTask('img', ['imagemin','copy']);
Nils Diewaldea236742015-03-26 21:55:36 +0000132 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000133 grunt.registerTask(
134 'default',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000135 ['requirejs', 'imagemin', 'copy', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000136 );
Nils Diewaldea236742015-03-26 21:55:36 +0000137};