blob: 1ca83620b9945b1dabfc878d8f2b9b4da1c708dd [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 : {
Akron49bfdbf2016-11-22 21:47:33 +010025 'lib': '../lib'
Nils Diewaldc2826192015-05-07 19:23:44 +000026 },
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: {
Akron49bfdbf2016-11-22 21:47:33 +010042 files: [{
43 expand: true,
44 cwd: 'dev/img/',
45 src: ['*.{png,gif,jpg}'],
46 dest: 'public/img/'
47 }]
Nils Diewaldea236742015-03-26 21:55:36 +000048 }
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',
Akron49bfdbf2016-11-22 21:47:33 +010057 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss',
Akronb56986f2017-06-29 20:52:29 +020058 'dev/css/kwic.css' : 'dev/scss/main/kwic.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000059 }
60 }
61 },
Nils Diewalda297f062015-04-02 00:23:46 +000062 jasmine: {
63 pivotal: {
Akron49bfdbf2016-11-22 21:47:33 +010064 src: [
65 'dev/js/src/menu.js',
66 'dev/js/src/match.js',
67 'dev/js/src/hint.js',
68 'dev/js/src/vc.js'
69 ],
70 options: {
71 specs: 'dev/js/spec/*Spec.js',
72 vendor: ['dev/js/lib/require.js']
73 }
Nils Diewalda297f062015-04-02 00:23:46 +000074 }
75 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000076 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000077 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000078 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000079 options: {
Akron49bfdbf2016-11-22 21:47:33 +010080 process:false
Nils Diewaldaa17d142015-04-08 23:32:23 +000081 },
82 main: {
Akron49bfdbf2016-11-22 21:47:33 +010083 files:[
84 {
85 expand: true,
86 cwd: 'dev/font/',
87 src: '**',
88 dest: 'public/font/',
89 filter: 'isFile',
90 nonull: true,
91 timestamp: true
92 },
93 {
94 expand: true,
95 cwd: 'dev/img/',
96 src: 'favicon.ico',
97 dest: 'public/',
98 filter: 'isFile',
99 nonull:true,
100 timestamp:true
101 },
102 {
103 expand: true,
104 cwd: 'dev/img/',
105 src: '*.svg',
106 dest: 'public/img/',
107 filter: 'isFile',
108 nonull:true,
109 timestamp:true
110 }
111 ]
Nils Diewaldaa17d142015-04-08 23:32:23 +0000112 }
Nils Diewaldce328112015-04-08 22:48:18 +0000113 },
Nils Diewaldea236742015-03-26 21:55:36 +0000114 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000115 css: {
Akron49bfdbf2016-11-22 21:47:33 +0100116 files: ['dev/scss/{util,base,fonts,kalamar,media}.scss',
117 'dev/scss/footer/footer.scss',
Akron189b3592016-01-04 20:56:46 +0100118 'dev/scss/sidebar/sidebar.scss',
Akron49bfdbf2016-11-22 21:47:33 +0100119 'dev/scss/header/{header,hint,menu,searchbar,vc,datepicker}.scss',
Akronb56986f2017-06-29 20:52:29 +0200120 'dev/scss/main/{alertify,koralquery,highlight,kwic,logos,tagger,' +
Akron15175132017-09-07 18:12:55 +0200121 'main,matchinfo,tree,pagination,query,'+
Akron49bfdbf2016-11-22 21:47:33 +0100122 'resultinfo,sidebar,tutorial}.scss'
123 ],
124 tasks: ['sass'],
125 options: {
126 spawn: false
127 }
Nils Diewaldea236742015-03-26 21:55:36 +0000128 }
Nils Diewald2488d052015-04-09 21:46:02 +0000129 }
Nils Diewaldea236742015-03-26 21:55:36 +0000130 });
131
Nils Diewaldea236742015-03-26 21:55:36 +0000132 grunt.loadNpmTasks('grunt-contrib-imagemin');
133 grunt.loadNpmTasks('grunt-contrib-watch');
134 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000135 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000136 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000137 grunt.loadNpmTasks('grunt-contrib-requirejs');
138
139 grunt.registerTask('default', ['requirejs']);
Nils Diewalda31a5152015-04-17 21:05:23 +0000140 grunt.registerTask('img', ['imagemin','copy']);
Akron9f64fd02016-02-13 05:51:38 +0100141 grunt.registerTask('js', ['requirejs']);
Nils Diewaldea236742015-03-26 21:55:36 +0000142 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000143 grunt.registerTask(
144 'default',
Nils Diewaldfccfbcb2015-04-29 20:48:19 +0000145 ['requirejs', 'imagemin', 'copy', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000146 );
Nils Diewaldea236742015-03-26 21:55:36 +0000147};