blob: ee186f77efbb1181cf6702a748ec48fbb626fb7e [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: {
Nils Diewalda944fab2015-04-08 21:02:04 +000070 specs: 'dev/js/spec/*Spec.js'
Nils Diewalda297f062015-04-02 00:23:46 +000071 }
72 }
73 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000074 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000075 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000076 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000077 options: {
78 process:false
79 },
80 main: {
81 files:[
82 {
83 expand: true,
84 cwd: 'dev/font/',
85 src: '**',
86 dest: 'public/font/',
87 filter: 'isFile',
88 nonull: true,
89 timestamp: true
90 },
91 {
Nils Diewald709f52f2015-05-21 18:32:58 +000092 expand: false,
Nils Diewaldaa17d142015-04-08 23:32:23 +000093 cwd: 'dev/img/',
94 src: 'favicon.ico',
95 dest: 'public/',
Nils Diewald709f52f2015-05-21 18:32:58 +000096 filter: 'isFile',
Nils Diewaldaa17d142015-04-08 23:32:23 +000097 nonull:true,
98 timestamp:true
Nils Diewaldfccfbcb2015-04-29 20:48:19 +000099 },
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000100 {
101 expand: true,
102 cwd: 'dev/img/',
Nils Diewald709f52f2015-05-21 18:32:58 +0000103 src: '*.svg',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000104 dest: 'public/img/',
Nils Diewald709f52f2015-05-21 18:32:58 +0000105 filter: 'isFile',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000106 nonull:true,
107 timestamp:true
Nils Diewaldaa17d142015-04-08 23:32:23 +0000108 }
109 ]
110 }
Nils Diewaldce328112015-04-08 22:48:18 +0000111 },
Nils Diewaldea236742015-03-26 21:55:36 +0000112 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000113 css: {
Nils Diewaldab4d3ca2015-04-17 01:48:43 +0000114 files: ['dev/scss/{util,base,fonts,kalamar,media}.scss',
115 'dev/scss/footer/footer.scss',
Nils Diewalda1228622015-04-25 01:59:10 +0000116 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss',
Nils Diewald4c221252015-04-21 20:19:25 +0000117 'dev/scss/main/{alertify,highlight,kwic,logos,' +
118 'main,matchinfo,pagination,query,'+
119 'resultinfo,sidebar,tutorial}.scss'
Nils Diewaldab4d3ca2015-04-17 01:48:43 +0000120 ],
Nils Diewaldea236742015-03-26 21:55:36 +0000121 tasks: ['sass'],
122 options: {
123 spawn: false
124 }
125 }
Nils Diewald2488d052015-04-09 21:46:02 +0000126 }
Nils Diewaldea236742015-03-26 21:55:36 +0000127 });
128
Nils Diewaldea236742015-03-26 21:55:36 +0000129 grunt.loadNpmTasks('grunt-contrib-imagemin');
130 grunt.loadNpmTasks('grunt-contrib-watch');
131 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000132 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000133 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000134 grunt.loadNpmTasks('grunt-contrib-requirejs');
135
136 grunt.registerTask('default', ['requirejs']);
Nils Diewalda31a5152015-04-17 21:05:23 +0000137 grunt.registerTask('img', ['imagemin','copy']);
Nils Diewaldea236742015-03-26 21:55:36 +0000138 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000139 grunt.registerTask(
140 'default',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000141 ['requirejs', 'imagemin', 'copy', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000142 );
Nils Diewaldea236742015-03-26 21:55:36 +0000143};