blob: b556928a0a5a2f7c2e9eb4a759a23fd01a8eb28d [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 var config;
Akron80055992017-12-20 16:30:52 +010019 var includeFile = 'default';
20 if (grunt.file.exists('kalamar.conf.js')) {
21 includeFile = 'root/kalamar.conf';
Akrone91da782017-12-15 17:17:50 +010022 };
23
24 // Generate requireJS files for l10n
25 var reqTasks = [];
26 for (var i in {'en' : 0, 'de' : 1}) {
27
Akrone91da782017-12-15 17:17:50 +010028 reqTasks.push({
29 options: {
Akron80055992017-12-20 16:30:52 +010030
Akrone91da782017-12-15 17:17:50 +010031 // optimize: "uglify",
32 baseUrl: 'dev/js/src',
33 paths : {
Akron80055992017-12-20 16:30:52 +010034 'lib': '../lib',
35 'root' : '../../..'
Akrone91da782017-12-15 17:17:50 +010036 },
Akron80055992017-12-20 16:30:52 +010037 wrap: true,
Akrone91da782017-12-15 17:17:50 +010038 // dir : 'public/js',
39 name: 'lib/almond',
Akron80055992017-12-20 16:30:52 +010040 include : [includeFile, "app/" + i],
Akrone91da782017-12-15 17:17:50 +010041 out: 'public/js/kalamar-<%= pkg.version %>-' + i + '.js'
42 }
43 })
44 };
45
Nils Diewaldea236742015-03-26 21:55:36 +000046 grunt.initConfig({
47 pkg: grunt.file.readJSON('package.json'),
Nils Diewaldc2826192015-05-07 19:23:44 +000048 requirejs: reqTasks,
Nils Diewaldea236742015-03-26 21:55:36 +000049 imagemin: {
50 dynamic: {
Akron49bfdbf2016-11-22 21:47:33 +010051 files: [{
52 expand: true,
53 cwd: 'dev/img/',
54 src: ['*.{png,gif,jpg}'],
55 dest: 'public/img/'
56 }]
Nils Diewaldea236742015-03-26 21:55:36 +000057 }
58 },
59 sass: {
60 dist: {
61 options: {
62 style: 'compressed'
63 },
64 files: {
Nils Diewaldce328112015-04-08 22:48:18 +000065 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss',
Akron49bfdbf2016-11-22 21:47:33 +010066 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss',
Akronb56986f2017-06-29 20:52:29 +020067 'dev/css/kwic.css' : 'dev/scss/main/kwic.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000068 }
69 }
70 },
Nils Diewalda297f062015-04-02 00:23:46 +000071 jasmine: {
72 pivotal: {
Akron49bfdbf2016-11-22 21:47:33 +010073 src: [
74 'dev/js/src/menu.js',
75 'dev/js/src/match.js',
76 'dev/js/src/hint.js',
77 'dev/js/src/vc.js'
78 ],
79 options: {
80 specs: 'dev/js/spec/*Spec.js',
81 vendor: ['dev/js/lib/require.js']
82 }
Nils Diewalda297f062015-04-02 00:23:46 +000083 }
84 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000085 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000086 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000087 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000088 options: {
Akron49bfdbf2016-11-22 21:47:33 +010089 process:false
Nils Diewaldaa17d142015-04-08 23:32:23 +000090 },
91 main: {
Akron49bfdbf2016-11-22 21:47:33 +010092 files:[
93 {
94 expand: true,
95 cwd: 'dev/font/',
96 src: '**',
97 dest: 'public/font/',
98 filter: 'isFile',
99 nonull: true,
100 timestamp: true
101 },
102 {
103 expand: true,
104 cwd: 'dev/img/',
105 src: 'favicon.ico',
106 dest: 'public/',
107 filter: 'isFile',
108 nonull:true,
109 timestamp:true
110 },
111 {
112 expand: true,
113 cwd: 'dev/img/',
114 src: '*.svg',
115 dest: 'public/img/',
116 filter: 'isFile',
117 nonull:true,
118 timestamp:true
119 }
120 ]
Nils Diewaldaa17d142015-04-08 23:32:23 +0000121 }
Nils Diewaldce328112015-04-08 22:48:18 +0000122 },
Nils Diewaldea236742015-03-26 21:55:36 +0000123 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000124 css: {
Akronae8f31c2017-11-28 18:05:52 +0100125 files: ['dev/scss/{util,base,fonts,kalamar,media,no-js}.scss',
Akron49bfdbf2016-11-22 21:47:33 +0100126 'dev/scss/footer/footer.scss',
Akron189b3592016-01-04 20:56:46 +0100127 'dev/scss/sidebar/sidebar.scss',
Akron49bfdbf2016-11-22 21:47:33 +0100128 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss',
Akronbd39a432017-09-20 13:57:13 +0200129 'dev/scss/main/{alertify,intro,koralquery,highlight,kwic,logos,tagger,' +
Akron15175132017-09-07 18:12:55 +0200130 'main,matchinfo,tree,pagination,query,'+
Akron49bfdbf2016-11-22 21:47:33 +0100131 'resultinfo,sidebar,tutorial}.scss'
132 ],
133 tasks: ['sass'],
134 options: {
135 spawn: false
136 }
Nils Diewaldea236742015-03-26 21:55:36 +0000137 }
Nils Diewald2488d052015-04-09 21:46:02 +0000138 }
Nils Diewaldea236742015-03-26 21:55:36 +0000139 });
140
Nils Diewaldea236742015-03-26 21:55:36 +0000141 grunt.loadNpmTasks('grunt-contrib-imagemin');
142 grunt.loadNpmTasks('grunt-contrib-watch');
143 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000144 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000145 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000146 grunt.loadNpmTasks('grunt-contrib-requirejs');
147
148 grunt.registerTask('default', ['requirejs']);
Nils Diewalda31a5152015-04-17 21:05:23 +0000149 grunt.registerTask('img', ['imagemin','copy']);
Akron9f64fd02016-02-13 05:51:38 +0100150 grunt.registerTask('js', ['requirejs']);
Nils Diewaldea236742015-03-26 21:55:36 +0000151 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000152 grunt.registerTask(
153 'default',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000154 ['requirejs', 'imagemin', 'copy', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000155 );
Nils Diewaldea236742015-03-26 21:55:36 +0000156};