blob: f83ce259ec5052630a7ebcf363f17d814d7fdc30 [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
14 * TODO: Use RequireJS
15 * http://addyosmani.com/writing-modular-js/
16 * http://qnundrum.com/question/393866
Nils Diewaldea236742015-03-26 21:55:36 +000017 */
Nils Diewaldea236742015-03-26 21:55:36 +000018module.exports = function(grunt) {
19 grunt.initConfig({
20 pkg: grunt.file.readJSON('package.json'),
21 concat: {
22 dist: {
23 src : [
Nils Diewalda944fab2015-04-08 21:02:04 +000024 'dev/js/lib/dagre/dagre.min.js',
25 'dev/js/src/menu.js',
26 'dev/js/src/match.js',
27 'dev/js/src/hint.js',
28 'dev/js/src/vc.js',
29 'dev/js/src/api.js',
30 'dev/js/src/session.js',
31 'dev/js/src/tutorial.js',
Nils Diewald2488d052015-04-09 21:46:02 +000032 'dev/js/src/init.js'
Nils Diewaldea236742015-03-26 21:55:36 +000033 ],
Nils Diewalda944fab2015-04-08 21:02:04 +000034 dest: 'dev/js/build/kalamar.js'
Nils Diewaldea236742015-03-26 21:55:36 +000035 }
36 },
37 uglify : {
38 build : {
Nils Diewalda944fab2015-04-08 21:02:04 +000039 src: 'dev/js/build/kalamar.js',
40 dest: 'public/js/kalamar-<%= pkg.version %>.js'
Nils Diewaldea236742015-03-26 21:55:36 +000041 }
42 },
43 imagemin: {
44 dynamic: {
45 files: [{
46 expand: true,
Nils Diewalda944fab2015-04-08 21:02:04 +000047 cwd: 'dev/img/',
Nils Diewalda297f062015-04-02 00:23:46 +000048 src: ['*.{png,gif,jpg,svg}'],
Nils Diewalda944fab2015-04-08 21:02:04 +000049 dest: 'public/img/'
Nils Diewaldea236742015-03-26 21:55:36 +000050 }]
51 }
52 },
53 sass: {
54 dist: {
55 options: {
56 style: 'compressed'
57 },
58 files: {
Nils Diewaldce328112015-04-08 22:48:18 +000059 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss',
60 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000061 }
62 }
63 },
Nils Diewalda297f062015-04-02 00:23:46 +000064 jasmine: {
65 pivotal: {
66 src: [
Nils Diewalda944fab2015-04-08 21:02:04 +000067 'dev/js/src/menu.js',
68 'dev/js/src/match.js',
69 'dev/js/src/match.js',
70 'dev/js/src/vc.js'
Nils Diewalda297f062015-04-02 00:23:46 +000071 ],
72 options: {
Nils Diewalda944fab2015-04-08 21:02:04 +000073 specs: 'dev/js/spec/*Spec.js'
Nils Diewalda297f062015-04-02 00:23:46 +000074 }
75 }
76 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000077 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000078 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000079 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000080 options: {
81 process:false
82 },
83 main: {
84 files:[
85 {
86 expand: true,
87 cwd: 'dev/font/',
88 src: '**',
89 dest: 'public/font/',
90 filter: 'isFile',
91 nonull: true,
92 timestamp: true
93 },
94 {
95 expand: true,
96 cwd: 'dev/img/',
97 src: 'favicon.ico',
98 dest: 'public/',
99 nonull:true,
100 timestamp:true
101 }
102 ]
103 }
Nils Diewaldce328112015-04-08 22:48:18 +0000104 },
Nils Diewaldea236742015-03-26 21:55:36 +0000105 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000106 css: {
Nils Diewald1c546922015-04-13 01:56:19 +0000107 files: ['dev/scss/{util,fonts,base,header,searchbar,matchinfo,resultinfo,kwic,menu,hint,pagination,logos,alertify,vc,media,kalamar,tutorial,query,sidebar,footer}.scss'],
Nils Diewaldea236742015-03-26 21:55:36 +0000108 tasks: ['sass'],
109 options: {
110 spawn: false
111 }
112 }
Nils Diewald2488d052015-04-09 21:46:02 +0000113 }
Nils Diewaldea236742015-03-26 21:55:36 +0000114 });
115
116 grunt.loadNpmTasks('grunt-contrib-concat');
117 grunt.loadNpmTasks('grunt-contrib-uglify');
118 grunt.loadNpmTasks('grunt-contrib-imagemin');
119 grunt.loadNpmTasks('grunt-contrib-watch');
120 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000121 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000122 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewaldea236742015-03-26 21:55:36 +0000123 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000124 grunt.registerTask(
125 'default',
126 ['copy', 'concat', 'uglify', 'imagemin', 'sass']
127 );
Nils Diewaldea236742015-03-26 21:55:36 +0000128};