blob: a85cfb5d39c00f2335dc1e83f1050f7ebd215e9b [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'),
Nils Diewald0e6992a2015-04-14 20:13:52 +000021 /*
Nils Diewaldea236742015-03-26 21:55:36 +000022 concat: {
23 dist: {
24 src : [
Nils Diewalda944fab2015-04-08 21:02:04 +000025 'dev/js/lib/dagre/dagre.min.js',
26 'dev/js/src/menu.js',
27 'dev/js/src/match.js',
28 'dev/js/src/hint.js',
29 'dev/js/src/vc.js',
30 'dev/js/src/api.js',
31 'dev/js/src/session.js',
32 'dev/js/src/tutorial.js',
Nils Diewald2488d052015-04-09 21:46:02 +000033 'dev/js/src/init.js'
Nils Diewaldea236742015-03-26 21:55:36 +000034 ],
Nils Diewalda944fab2015-04-08 21:02:04 +000035 dest: 'dev/js/build/kalamar.js'
Nils Diewaldea236742015-03-26 21:55:36 +000036 }
37 },
38 uglify : {
39 build : {
Nils Diewalda944fab2015-04-08 21:02:04 +000040 src: 'dev/js/build/kalamar.js',
41 dest: 'public/js/kalamar-<%= pkg.version %>.js'
Nils Diewaldea236742015-03-26 21:55:36 +000042 }
43 },
Nils Diewald0e6992a2015-04-14 20:13:52 +000044 */
45 requirejs: {
46 compile: {
47 options: {
48 // optimize: "uglify",
49 baseUrl: 'dev/js/src',
50 paths : {
51 'lib': '../lib'
52 },
53 wrap:true,
54 include : ['init'],
55 insertRequire: ['init'],
56 name: 'lib/almond',
57 out: 'public/js/kalamar-<%= pkg.version %>.js'
58 }
59 }
60 },
Nils Diewaldea236742015-03-26 21:55:36 +000061 imagemin: {
62 dynamic: {
63 files: [{
64 expand: true,
Nils Diewalda944fab2015-04-08 21:02:04 +000065 cwd: 'dev/img/',
Nils Diewalda297f062015-04-02 00:23:46 +000066 src: ['*.{png,gif,jpg,svg}'],
Nils Diewalda944fab2015-04-08 21:02:04 +000067 dest: 'public/img/'
Nils Diewaldea236742015-03-26 21:55:36 +000068 }]
69 }
70 },
71 sass: {
72 dist: {
73 options: {
74 style: 'compressed'
75 },
76 files: {
Nils Diewaldce328112015-04-08 22:48:18 +000077 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss',
78 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000079 }
80 }
81 },
Nils Diewalda297f062015-04-02 00:23:46 +000082 jasmine: {
83 pivotal: {
84 src: [
Nils Diewalda944fab2015-04-08 21:02:04 +000085 'dev/js/src/menu.js',
86 'dev/js/src/match.js',
87 'dev/js/src/match.js',
88 'dev/js/src/vc.js'
Nils Diewalda297f062015-04-02 00:23:46 +000089 ],
90 options: {
Nils Diewalda944fab2015-04-08 21:02:04 +000091 specs: 'dev/js/spec/*Spec.js'
Nils Diewalda297f062015-04-02 00:23:46 +000092 }
93 }
94 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000095 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000096 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000097 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000098 options: {
99 process:false
100 },
101 main: {
102 files:[
103 {
104 expand: true,
105 cwd: 'dev/font/',
106 src: '**',
107 dest: 'public/font/',
108 filter: 'isFile',
109 nonull: true,
110 timestamp: true
111 },
112 {
113 expand: true,
114 cwd: 'dev/img/',
115 src: 'favicon.ico',
116 dest: 'public/',
117 nonull:true,
118 timestamp:true
119 }
120 ]
121 }
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: {
Nils Diewald1c546922015-04-13 01:56:19 +0000125 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 +0000126 tasks: ['sass'],
127 options: {
128 spawn: false
129 }
130 }
Nils Diewald2488d052015-04-09 21:46:02 +0000131 }
Nils Diewaldea236742015-03-26 21:55:36 +0000132 });
133
134 grunt.loadNpmTasks('grunt-contrib-concat');
135 grunt.loadNpmTasks('grunt-contrib-uglify');
136 grunt.loadNpmTasks('grunt-contrib-imagemin');
137 grunt.loadNpmTasks('grunt-contrib-watch');
138 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000139 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000140 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000141 grunt.loadNpmTasks('grunt-contrib-requirejs');
142
143 grunt.registerTask('default', ['requirejs']);
144
Nils Diewaldea236742015-03-26 21:55:36 +0000145 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000146 grunt.registerTask(
147 'default',
Nils Diewald0e6992a2015-04-14 20:13:52 +0000148 ['copy', 'requirejs', 'imagemin', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000149 );
Nils Diewaldea236742015-03-26 21:55:36 +0000150};