blob: fa98b1a8f556fdd93b5f31279adf8d46a9c56cc0 [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 requirejs: {
22 compile: {
23 options: {
24 // optimize: "uglify",
25 baseUrl: 'dev/js/src',
26 paths : {
27 'lib': '../lib'
28 },
29 wrap:true,
Nils Diewald7c8ced22015-04-15 19:21:00 +000030 include : ['app'],
31 insertRequire: ['app'],
Nils Diewald0e6992a2015-04-14 20:13:52 +000032 name: 'lib/almond',
33 out: 'public/js/kalamar-<%= pkg.version %>.js'
34 }
35 }
36 },
Nils Diewaldea236742015-03-26 21:55:36 +000037 imagemin: {
38 dynamic: {
39 files: [{
40 expand: true,
Nils Diewalda944fab2015-04-08 21:02:04 +000041 cwd: 'dev/img/',
Nils Diewalda297f062015-04-02 00:23:46 +000042 src: ['*.{png,gif,jpg,svg}'],
Nils Diewalda944fab2015-04-08 21:02:04 +000043 dest: 'public/img/'
Nils Diewaldea236742015-03-26 21:55:36 +000044 }]
45 }
46 },
47 sass: {
48 dist: {
49 options: {
50 style: 'compressed'
51 },
52 files: {
Nils Diewaldce328112015-04-08 22:48:18 +000053 'public/css/kalamar-<%= pkg.version %>.css' : 'dev/scss/kalamar.scss',
54 'dev/css/kalamar.css' : 'dev/scss/kalamar.scss'
Nils Diewaldea236742015-03-26 21:55:36 +000055 }
56 }
57 },
Nils Diewalda297f062015-04-02 00:23:46 +000058 jasmine: {
59 pivotal: {
60 src: [
Nils Diewalda944fab2015-04-08 21:02:04 +000061 'dev/js/src/menu.js',
62 'dev/js/src/match.js',
63 'dev/js/src/match.js',
64 'dev/js/src/vc.js'
Nils Diewalda297f062015-04-02 00:23:46 +000065 ],
66 options: {
Nils Diewalda944fab2015-04-08 21:02:04 +000067 specs: 'dev/js/spec/*Spec.js'
Nils Diewalda297f062015-04-02 00:23:46 +000068 }
69 }
70 },
Nils Diewaldaa17d142015-04-08 23:32:23 +000071 // see https://github.com/gruntjs/grunt-contrib-copy/issues/64
Nils Diewald2488d052015-04-09 21:46:02 +000072 // for copying binary files
Nils Diewaldce328112015-04-08 22:48:18 +000073 copy : {
Nils Diewaldaa17d142015-04-08 23:32:23 +000074 options: {
75 process:false
76 },
77 main: {
78 files:[
79 {
80 expand: true,
81 cwd: 'dev/font/',
82 src: '**',
83 dest: 'public/font/',
84 filter: 'isFile',
85 nonull: true,
86 timestamp: true
87 },
88 {
89 expand: true,
90 cwd: 'dev/img/',
91 src: 'favicon.ico',
92 dest: 'public/',
93 nonull:true,
94 timestamp:true
95 }
96 ]
97 }
Nils Diewaldce328112015-04-08 22:48:18 +000098 },
Nils Diewaldea236742015-03-26 21:55:36 +000099 watch: {
Nils Diewaldea236742015-03-26 21:55:36 +0000100 css: {
Nils Diewald1c546922015-04-13 01:56:19 +0000101 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 +0000102 tasks: ['sass'],
103 options: {
104 spawn: false
105 }
106 }
Nils Diewald2488d052015-04-09 21:46:02 +0000107 }
Nils Diewaldea236742015-03-26 21:55:36 +0000108 });
109
Nils Diewaldea236742015-03-26 21:55:36 +0000110 grunt.loadNpmTasks('grunt-contrib-imagemin');
111 grunt.loadNpmTasks('grunt-contrib-watch');
112 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000113 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000114 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000115 grunt.loadNpmTasks('grunt-contrib-requirejs');
116
117 grunt.registerTask('default', ['requirejs']);
118
Nils Diewaldea236742015-03-26 21:55:36 +0000119 grunt.registerTask('css', ['sass']);
Nils Diewaldce328112015-04-08 22:48:18 +0000120 grunt.registerTask(
121 'default',
Nils Diewald0e6992a2015-04-14 20:13:52 +0000122 ['copy', 'requirejs', 'imagemin', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000123 );
Nils Diewaldea236742015-03-26 21:55:36 +0000124};