blob: 76c187ce5395bb20cb06ebcb95f69485dabb0fd6 [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 Diewaldc2826192015-05-07 19:23:44 +000016
17// Generate requireJS files for l10n
18var reqTasks = [];
19for (var i in {'en' : 0, 'de' : 1}) {
20 reqTasks.push({
21 options: {
22 // optimize: "uglify",
23 baseUrl: 'dev/js/src',
24 paths : {
25 'lib': '../lib'
26 },
27 wrap:true,
28 // dir : 'public/js',
29 name: 'lib/almond',
30 include : ['app/' + i],
31 out: 'public/js/kalamar-<%= pkg.version %>-' + i + '.js'
32 }
33 })
34};
35
Nils Diewaldea236742015-03-26 21:55:36 +000036module.exports = function(grunt) {
37 grunt.initConfig({
38 pkg: grunt.file.readJSON('package.json'),
Nils Diewaldc2826192015-05-07 19:23:44 +000039 requirejs: reqTasks,
Nils Diewaldea236742015-03-26 21:55:36 +000040 imagemin: {
41 dynamic: {
42 files: [{
43 expand: true,
Nils Diewalda944fab2015-04-08 21:02:04 +000044 cwd: 'dev/img/',
Nils Diewald709f52f2015-05-21 18:32:58 +000045 src: ['*.{png,gif,jpg}'],
Nils Diewalda944fab2015-04-08 21:02:04 +000046 dest: 'public/img/'
Nils Diewaldea236742015-03-26 21:55:36 +000047 }]
48 }
49 },
50 sass: {
51 dist: {
52 options: {
53 style: 'compressed'
54 },
55 files: {
Nils Diewaldce328112015-04-08 22:48:18 +000056 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss',
57 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000058 }
59 }
60 },
Nils Diewalda297f062015-04-02 00:23:46 +000061 jasmine: {
62 pivotal: {
63 src: [
Nils Diewalda944fab2015-04-08 21:02:04 +000064 'dev/js/src/menu.js',
65 'dev/js/src/match.js',
Nils Diewalda1228622015-04-25 01:59:10 +000066 'dev/js/src/hint.js',
Nils Diewalda944fab2015-04-08 21:02:04 +000067 'dev/js/src/vc.js'
Nils Diewalda297f062015-04-02 00:23:46 +000068 ],
69 options: {
Akron0c87a5e2016-08-01 19:53:43 +020070 specs: 'dev/js/spec/*Spec.js',
71 vendor: ['dev/js/lib/require.js']
Nils Diewalda297f062015-04-02 00:23:46 +000072 }
73 }
74 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000075 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000076 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000077 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000078 options: {
79 process:false
80 },
81 main: {
82 files:[
83 {
84 expand: true,
85 cwd: 'dev/font/',
86 src: '**',
87 dest: 'public/font/',
88 filter: 'isFile',
89 nonull: true,
90 timestamp: true
91 },
92 {
Nils Diewald023c6712015-05-21 20:12:30 +000093 expand: true,
Nils Diewaldaa17d142015-04-08 23:32:23 +000094 cwd: 'dev/img/',
95 src: 'favicon.ico',
96 dest: 'public/',
Nils Diewald709f52f2015-05-21 18:32:58 +000097 filter: 'isFile',
Nils Diewaldaa17d142015-04-08 23:32:23 +000098 nonull:true,
99 timestamp:true
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000100 },
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000101 {
102 expand: true,
103 cwd: 'dev/img/',
Nils Diewald709f52f2015-05-21 18:32:58 +0000104 src: '*.svg',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000105 dest: 'public/img/',
Nils Diewald709f52f2015-05-21 18:32:58 +0000106 filter: 'isFile',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000107 nonull:true,
108 timestamp:true
Nils Diewaldaa17d142015-04-08 23:32:23 +0000109 }
110 ]
111 }
Nils Diewaldce328112015-04-08 22:48:18 +0000112 },
Nils Diewaldea236742015-03-26 21:55:36 +0000113 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000114 css: {
Nils Diewaldab4d3ca2015-04-17 01:48:43 +0000115 files: ['dev/scss/{util,base,fonts,kalamar,media}.scss',
116 'dev/scss/footer/footer.scss',
Nils Diewalda1228622015-04-25 01:59:10 +0000117 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss',
Akron88490f22015-11-30 15:07:08 +0100118 'dev/scss/main/{alertify,koralquery,highlight,kwic,logos,tagger,' +
Nils Diewald4c221252015-04-21 20:19:25 +0000119 'main,matchinfo,pagination,query,'+
120 'resultinfo,sidebar,tutorial}.scss'
Nils Diewaldab4d3ca2015-04-17 01:48:43 +0000121 ],
Nils Diewaldea236742015-03-26 21:55:36 +0000122 tasks: ['sass'],
123 options: {
124 spawn: false
125 }
126 }
Nils Diewald2488d052015-04-09 21:46:02 +0000127 }
Nils Diewaldea236742015-03-26 21:55:36 +0000128 });
129
Nils Diewaldea236742015-03-26 21:55:36 +0000130 grunt.loadNpmTasks('grunt-contrib-imagemin');
131 grunt.loadNpmTasks('grunt-contrib-watch');
132 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000133 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000134 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000135 grunt.loadNpmTasks('grunt-contrib-requirejs');
136
137 grunt.registerTask('default', ['requirejs']);
Nils Diewalda31a5152015-04-17 21:05:23 +0000138 grunt.registerTask('img', ['imagemin','copy']);
Akron9f64fd02016-02-13 05:51:38 +0100139 grunt.registerTask('js', ['requirejs']);
Nils Diewaldea236742015-03-26 21:55:36 +0000140 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000141 grunt.registerTask(
142 'default',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000143 ['requirejs', 'imagemin', 'copy', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000144 );
Nils Diewaldea236742015-03-26 21:55:36 +0000145};