blob: 7901237de0fe7adbce475da1fb5fbe929d2a6b2b [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 },
Nils Diewald7148c6f2015-05-04 15:07:53 +000027
28 // TODO: add language versions
Nils Diewald0e6992a2015-04-14 20:13:52 +000029 wrap:true,
Nils Diewald7148c6f2015-05-04 15:07:53 +000030 include : ['app/en'],
31 insertRequire: ['app/en'],
Nils Diewald0e6992a2015-04-14 20:13:52 +000032 name: 'lib/almond',
Nils Diewald7148c6f2015-05-04 15:07:53 +000033 out: 'public/js/kalamar-<%= pkg.version %>-en.js'
Nils Diewald0e6992a2015-04-14 20:13:52 +000034 }
35 }
36 },
Nils Diewaldea236742015-03-26 21:55:36 +000037 imagemin: {
38 dynamic: {
39 files: [{
40 expand: true,
Nils Diewalda944fab2015-04-08 21:02:04 +000041 cwd: 'dev/img/',
Nils Diewalda297f062015-04-02 00:23:46 +000042 src: ['*.{png,gif,jpg,svg}'],
Nils Diewalda944fab2015-04-08 21:02:04 +000043 dest: 'public/img/'
Nils Diewaldea236742015-03-26 21:55:36 +000044 }]
45 }
46 },
47 sass: {
48 dist: {
49 options: {
50 style: 'compressed'
51 },
52 files: {
Nils Diewaldce328112015-04-08 22:48:18 +000053 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss',
54 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000055 }
56 }
57 },
Nils Diewalda297f062015-04-02 00:23:46 +000058 jasmine: {
59 pivotal: {
60 src: [
Nils Diewalda944fab2015-04-08 21:02:04 +000061 'dev/js/src/menu.js',
62 'dev/js/src/match.js',
Nils Diewalda1228622015-04-25 01:59:10 +000063 'dev/js/src/hint.js',
Nils Diewalda944fab2015-04-08 21:02:04 +000064 'dev/js/src/vc.js'
Nils Diewalda297f062015-04-02 00:23:46 +000065 ],
66 options: {
Nils Diewalda944fab2015-04-08 21:02:04 +000067 specs: 'dev/js/spec/*Spec.js'
Nils Diewalda297f062015-04-02 00:23:46 +000068 }
69 }
70 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000071 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000072 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000073 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000074 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
Nils Diewaldfccfbcb2015-04-29 20:48:19 +000095 },
96 // Needs to overwrite the prepared svg as it corrupts the embedded js
97 {
98 expand: true,
99 cwd: 'dev/img/',
100 src: 'korap-overview.svg',
101 dest: 'public/img/',
102 nonull:true,
103 timestamp:true
Nils Diewaldaa17d142015-04-08 23:32:23 +0000104 }
105 ]
106 }
Nils Diewaldce328112015-04-08 22:48:18 +0000107 },
Nils Diewaldea236742015-03-26 21:55:36 +0000108 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000109 css: {
Nils Diewaldab4d3ca2015-04-17 01:48:43 +0000110 files: ['dev/scss/{util,base,fonts,kalamar,media}.scss',
111 'dev/scss/footer/footer.scss',
Nils Diewalda1228622015-04-25 01:59:10 +0000112 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss',
Nils Diewald4c221252015-04-21 20:19:25 +0000113 'dev/scss/main/{alertify,highlight,kwic,logos,' +
114 'main,matchinfo,pagination,query,'+
115 'resultinfo,sidebar,tutorial}.scss'
Nils Diewaldab4d3ca2015-04-17 01:48:43 +0000116 ],
Nils Diewaldea236742015-03-26 21:55:36 +0000117 tasks: ['sass'],
118 options: {
119 spawn: false
120 }
121 }
Nils Diewald2488d052015-04-09 21:46:02 +0000122 }
Nils Diewaldea236742015-03-26 21:55:36 +0000123 });
124
Nils Diewaldea236742015-03-26 21:55:36 +0000125 grunt.loadNpmTasks('grunt-contrib-imagemin');
126 grunt.loadNpmTasks('grunt-contrib-watch');
127 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000128 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000129 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000130 grunt.loadNpmTasks('grunt-contrib-requirejs');
131
132 grunt.registerTask('default', ['requirejs']);
Nils Diewalda31a5152015-04-17 21:05:23 +0000133 grunt.registerTask('img', ['imagemin','copy']);
Nils Diewaldea236742015-03-26 21:55:36 +0000134 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000135 grunt.registerTask(
136 'default',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000137 ['requirejs', 'imagemin', 'copy', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000138 );
Nils Diewaldea236742015-03-26 21:55:36 +0000139};