blob: 454faef174257477eeea4ac5ae410f320224f4ac [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 = [];
Akron70821ba2018-07-16 17:24:36 +020026 var uglyFiles = {};
Akrone91da782017-12-15 17:17:50 +010027 for (var i in {'en' : 0, 'de' : 1}) {
28
Akrone91da782017-12-15 17:17:50 +010029 reqTasks.push({
30 options: {
Akron80055992017-12-20 16:30:52 +010031
Akron70821ba2018-07-16 17:24:36 +020032 optimize: "none",
Akrone91da782017-12-15 17:17:50 +010033 baseUrl: 'dev/js/src',
34 paths : {
Akron80055992017-12-20 16:30:52 +010035 'lib': '../lib',
36 'root' : '../../..'
Akrone91da782017-12-15 17:17:50 +010037 },
Akron80055992017-12-20 16:30:52 +010038 wrap: true,
Akrone91da782017-12-15 17:17:50 +010039 // dir : 'public/js',
40 name: 'lib/almond',
Akron80055992017-12-20 16:30:52 +010041 include : [includeFile, "app/" + i],
Akrone91da782017-12-15 17:17:50 +010042 out: 'public/js/kalamar-<%= pkg.version %>-' + i + '.js'
43 }
Akron70821ba2018-07-16 17:24:36 +020044 });
45
46 uglyFiles['public/js/kalamar-<%= pkg.version %>-' + i + '.js'] = ['public/js/kalamar-<%= pkg.version %>-' + i + '.js'];
Akrone91da782017-12-15 17:17:50 +010047 };
48
Nils Diewaldea236742015-03-26 21:55:36 +000049 grunt.initConfig({
50 pkg: grunt.file.readJSON('package.json'),
Nils Diewaldc2826192015-05-07 19:23:44 +000051 requirejs: reqTasks,
Akron70821ba2018-07-16 17:24:36 +020052 uglify: {
53 kalamar : {
54 files: uglyFiles
55 }
56 },
Nils Diewaldea236742015-03-26 21:55:36 +000057 imagemin: {
58 dynamic: {
Akron49bfdbf2016-11-22 21:47:33 +010059 files: [{
60 expand: true,
61 cwd: 'dev/img/',
62 src: ['*.{png,gif,jpg}'],
63 dest: 'public/img/'
64 }]
Nils Diewaldea236742015-03-26 21:55:36 +000065 }
66 },
67 sass: {
68 dist: {
69 options: {
70 style: 'compressed'
71 },
72 files: {
Nils Diewaldce328112015-04-08 22:48:18 +000073 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss',
Akron49bfdbf2016-11-22 21:47:33 +010074 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss',
Akronb56986f2017-06-29 20:52:29 +020075 'dev/css/kwic.css' : 'dev/scss/main/kwic.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000076 }
77 }
78 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000079 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000080 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000081 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000082 options: {
Akron49bfdbf2016-11-22 21:47:33 +010083 process:false
Nils Diewaldaa17d142015-04-08 23:32:23 +000084 },
85 main: {
Akron49bfdbf2016-11-22 21:47:33 +010086 files:[
87 {
88 expand: true,
89 cwd: 'dev/font/',
90 src: '**',
91 dest: 'public/font/',
92 filter: 'isFile',
93 nonull: true,
94 timestamp: true
95 },
96 {
97 expand: true,
98 cwd: 'dev/img/',
99 src: 'favicon.ico',
100 dest: 'public/',
101 filter: 'isFile',
102 nonull:true,
103 timestamp:true
104 },
105 {
106 expand: true,
107 cwd: 'dev/img/',
108 src: '*.svg',
109 dest: 'public/img/',
110 filter: 'isFile',
111 nonull:true,
112 timestamp:true
113 }
114 ]
Nils Diewaldaa17d142015-04-08 23:32:23 +0000115 }
Nils Diewaldce328112015-04-08 22:48:18 +0000116 },
Nils Diewaldea236742015-03-26 21:55:36 +0000117 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000118 css: {
Akronae8f31c2017-11-28 18:05:52 +0100119 files: ['dev/scss/{util,base,fonts,kalamar,media,no-js}.scss',
Akron49bfdbf2016-11-22 21:47:33 +0100120 'dev/scss/footer/footer.scss',
Akron189b3592016-01-04 20:56:46 +0100121 'dev/scss/sidebar/sidebar.scss',
Akron49bfdbf2016-11-22 21:47:33 +0100122 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss',
Akronbd39a432017-09-20 13:57:13 +0200123 'dev/scss/main/{alertify,intro,koralquery,highlight,kwic,logos,tagger,' +
Akron537bc522018-07-13 19:06:27 +0200124 'main,matchinfo,panel,tree,pagination,query,'+
Akronbec4a6a2018-07-10 14:45:15 +0200125 'resultinfo,sidebar,tutorial,buttongroup}.scss'
Akron49bfdbf2016-11-22 21:47:33 +0100126 ],
127 tasks: ['sass'],
128 options: {
129 spawn: false
130 }
Nils Diewaldea236742015-03-26 21:55:36 +0000131 }
Nils Diewald2488d052015-04-09 21:46:02 +0000132 }
Nils Diewaldea236742015-03-26 21:55:36 +0000133 });
134
Nils Diewaldea236742015-03-26 21:55:36 +0000135 grunt.loadNpmTasks('grunt-contrib-imagemin');
136 grunt.loadNpmTasks('grunt-contrib-watch');
137 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewaldce328112015-04-08 22:48:18 +0000138 grunt.loadNpmTasks('grunt-contrib-copy');
Akron70821ba2018-07-16 17:24:36 +0200139 grunt.loadNpmTasks('grunt-contrib-uglify-es');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000140 grunt.loadNpmTasks('grunt-contrib-requirejs');
141
Nils Diewalda31a5152015-04-17 21:05:23 +0000142 grunt.registerTask('img', ['imagemin','copy']);
Akron9f64fd02016-02-13 05:51:38 +0100143 grunt.registerTask('js', ['requirejs']);
Nils Diewaldea236742015-03-26 21:55:36 +0000144 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000145 grunt.registerTask(
146 'default',
Akron70821ba2018-07-16 17:24:36 +0200147 ['requirejs', 'uglify', 'imagemin', 'copy', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000148 );
Nils Diewaldea236742015-03-26 21:55:36 +0000149};