blob: 830a0eb8e484a67b4d2a88075d78f2384370a0a5 [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
Nils Diewaldea236742015-03-26 21:55:36 +000017module.exports = function(grunt) {
Akrone91da782017-12-15 17:17:50 +010018
19 var config;
20
21 try {
22 config = grunt.file.readJSON('kalamar.conf.json');
23 }
24 catch(err) {
25 console.log("Error: " + err);
26 config = {};
27 };
28
29 if (config["include"] === undefined) {
30 config["include"] = [
31 'hint/foundries/base',
32 'hint/foundries/dereko'
33 ];
34 };
35
36 // Generate requireJS files for l10n
37 var reqTasks = [];
38 for (var i in {'en' : 0, 'de' : 1}) {
39
40 var includeFiles = config["include"].slice();
41 includeFiles.push('app/' + i);
42
43 reqTasks.push({
44 options: {
45 // optimize: "uglify",
46 baseUrl: 'dev/js/src',
47 paths : {
48 'lib': '../lib'
49 },
50 wrap:true,
51 // dir : 'public/js',
52 name: 'lib/almond',
53 include : includeFiles,
54 out: 'public/js/kalamar-<%= pkg.version %>-' + i + '.js'
55 }
56 })
57 };
58
Nils Diewaldea236742015-03-26 21:55:36 +000059 grunt.initConfig({
60 pkg: grunt.file.readJSON('package.json'),
Nils Diewaldc2826192015-05-07 19:23:44 +000061 requirejs: reqTasks,
Nils Diewaldea236742015-03-26 21:55:36 +000062 imagemin: {
63 dynamic: {
Akron49bfdbf2016-11-22 21:47:33 +010064 files: [{
65 expand: true,
66 cwd: 'dev/img/',
67 src: ['*.{png,gif,jpg}'],
68 dest: 'public/img/'
69 }]
Nils Diewaldea236742015-03-26 21:55:36 +000070 }
71 },
72 sass: {
73 dist: {
74 options: {
75 style: 'compressed'
76 },
77 files: {
Nils Diewaldce328112015-04-08 22:48:18 +000078 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss',
Akron49bfdbf2016-11-22 21:47:33 +010079 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss',
Akronb56986f2017-06-29 20:52:29 +020080 'dev/css/kwic.css' : 'dev/scss/main/kwic.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000081 }
82 }
83 },
Nils Diewalda297f062015-04-02 00:23:46 +000084 jasmine: {
85 pivotal: {
Akron49bfdbf2016-11-22 21:47:33 +010086 src: [
87 'dev/js/src/menu.js',
88 'dev/js/src/match.js',
89 'dev/js/src/hint.js',
90 'dev/js/src/vc.js'
91 ],
92 options: {
93 specs: 'dev/js/spec/*Spec.js',
94 vendor: ['dev/js/lib/require.js']
95 }
Nils Diewalda297f062015-04-02 00:23:46 +000096 }
97 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000098 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000099 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +0000100 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +0000101 options: {
Akron49bfdbf2016-11-22 21:47:33 +0100102 process:false
Nils Diewaldaa17d142015-04-08 23:32:23 +0000103 },
104 main: {
Akron49bfdbf2016-11-22 21:47:33 +0100105 files:[
106 {
107 expand: true,
108 cwd: 'dev/font/',
109 src: '**',
110 dest: 'public/font/',
111 filter: 'isFile',
112 nonull: true,
113 timestamp: true
114 },
115 {
116 expand: true,
117 cwd: 'dev/img/',
118 src: 'favicon.ico',
119 dest: 'public/',
120 filter: 'isFile',
121 nonull:true,
122 timestamp:true
123 },
124 {
125 expand: true,
126 cwd: 'dev/img/',
127 src: '*.svg',
128 dest: 'public/img/',
129 filter: 'isFile',
130 nonull:true,
131 timestamp:true
132 }
133 ]
Nils Diewaldaa17d142015-04-08 23:32:23 +0000134 }
Nils Diewaldce328112015-04-08 22:48:18 +0000135 },
Nils Diewaldea236742015-03-26 21:55:36 +0000136 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000137 css: {
Akronae8f31c2017-11-28 18:05:52 +0100138 files: ['dev/scss/{util,base,fonts,kalamar,media,no-js}.scss',
Akron49bfdbf2016-11-22 21:47:33 +0100139 'dev/scss/footer/footer.scss',
Akron189b3592016-01-04 20:56:46 +0100140 'dev/scss/sidebar/sidebar.scss',
Akron49bfdbf2016-11-22 21:47:33 +0100141 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss',
Akronbd39a432017-09-20 13:57:13 +0200142 'dev/scss/main/{alertify,intro,koralquery,highlight,kwic,logos,tagger,' +
Akron15175132017-09-07 18:12:55 +0200143 'main,matchinfo,tree,pagination,query,'+
Akron49bfdbf2016-11-22 21:47:33 +0100144 'resultinfo,sidebar,tutorial}.scss'
145 ],
146 tasks: ['sass'],
147 options: {
148 spawn: false
149 }
Nils Diewaldea236742015-03-26 21:55:36 +0000150 }
Nils Diewald2488d052015-04-09 21:46:02 +0000151 }
Nils Diewaldea236742015-03-26 21:55:36 +0000152 });
153
Nils Diewaldea236742015-03-26 21:55:36 +0000154 grunt.loadNpmTasks('grunt-contrib-imagemin');
155 grunt.loadNpmTasks('grunt-contrib-watch');
156 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000157 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000158 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000159 grunt.loadNpmTasks('grunt-contrib-requirejs');
160
161 grunt.registerTask('default', ['requirejs']);
Nils Diewalda31a5152015-04-17 21:05:23 +0000162 grunt.registerTask('img', ['imagemin','copy']);
Akron9f64fd02016-02-13 05:51:38 +0100163 grunt.registerTask('js', ['requirejs']);
Nils Diewaldea236742015-03-26 21:55:36 +0000164 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000165 grunt.registerTask(
166 'default',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000167 ['requirejs', 'imagemin', 'copy', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000168 );
Nils Diewaldea236742015-03-26 21:55:36 +0000169};