blob: 7e9edf816007e0dd99f340175db51ecd73f18b90 [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 Diewaldab4d3ca2015-04-17 01:48:43 +0000101 files: ['dev/scss/{util,base,fonts,kalamar,media}.scss',
102 'dev/scss/footer/footer.scss',
103 'dev/scss/header/{header,hint,menu,searchbar,vc}.scss',
104 'dev/scss/main/{alertify,highlight,kwic,logos,main,matchinfo,pagination,query,resultinfo,sidebar,tutorial}.scss'
105 ],
Nils Diewaldea236742015-03-26 21:55:36 +0000106 tasks: ['sass'],
107 options: {
108 spawn: false
109 }
110 }
Nils Diewald2488d052015-04-09 21:46:02 +0000111 }
Nils Diewaldea236742015-03-26 21:55:36 +0000112 });
113
Nils Diewaldea236742015-03-26 21:55:36 +0000114 grunt.loadNpmTasks('grunt-contrib-imagemin');
115 grunt.loadNpmTasks('grunt-contrib-watch');
116 grunt.loadNpmTasks('grunt-contrib-sass');
Nils Diewalda297f062015-04-02 00:23:46 +0000117 grunt.loadNpmTasks('grunt-contrib-jasmine');
Nils Diewaldce328112015-04-08 22:48:18 +0000118 grunt.loadNpmTasks('grunt-contrib-copy');
Nils Diewald0e6992a2015-04-14 20:13:52 +0000119 grunt.loadNpmTasks('grunt-contrib-requirejs');
120
121 grunt.registerTask('default', ['requirejs']);
Nils Diewalda31a5152015-04-17 21:05:23 +0000122 grunt.registerTask('img', ['imagemin','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',
Nils Diewald0e6992a2015-04-14 20:13:52 +0000126 ['copy', 'requirejs', 'imagemin', 'sass']
Nils Diewaldce328112015-04-08 22:48:18 +0000127 );
Nils Diewaldea236742015-03-26 21:55:36 +0000128};