]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/Gruntfile.js
webstaff: add egJsonExporter directive
[Evergreen.git] / Open-ILS / web / js / ui / default / staff / Gruntfile.js
1 module.exports = function(grunt) {
2
3   // Project configuration.
4   var config = { 
5     pkg: grunt.file.readJSON('package.json'),
6
7     // copy the files we care about from bower-fetched dependencies
8     // into our build directory
9     copy: {
10
11       js : {
12         files: [{ 
13           dest: 'build/js/', 
14           flatten: true,
15           filter: 'isFile',
16           expand : true,
17           src: [
18             'bower_components/angular/angular.min.js',
19             'bower_components/angular/angular.min.js.map',
20             'bower_components/angular-route/angular-route.min.js',
21             'bower_components/angular-route/angular-route.min.js.map',
22             'bower_components/angular-bootstrap/ui-bootstrap.min.js',
23             'bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
24             'bower_components/angular-hotkeys/build/hotkeys.min.js',
25             'bower_components/angular-file-saver/dist/angular-file-saver.bundle.min.js',
26             'bower_components/angular-location-update/angular-location-update.min.js',
27             'bower_components/jquery/dist/jquery.min.js',
28           ]
29         }]
30       },
31
32       css : {
33         files : [{
34           dest : 'build/css/',
35           flatten : true,
36           filter : 'isFile',
37           expand : true,
38           src : [
39             'bower_components/angular-hotkeys/build/hotkeys.min.css',
40             'bower_components/bootstrap/dist/css/bootstrap.min.css' 
41           ]
42         }]
43       },
44
45       fonts : {
46         files : [{
47           dest : 'build/fonts/',
48           flatten : true,
49           filter : 'isFile',
50           expand : true,
51           src : [
52             'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot',
53             'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg',
54             'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf',
55             'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff'
56           ]
57         }]
58       }
59     },
60
61     // combine our CSS deps
62     // note: minification also supported, but not required (yet).
63     cssmin: {
64       combine: {
65         files: {
66           'build/css/evergreen-staff-client-deps.<%= pkg.version %>.min.css' : [
67             'build/css/hotkeys.min.css',
68             'build/css/bootstrap.min.css'
69           ]
70         }
71       }
72     },
73
74     // concatenation + minification
75     uglify: {
76       options: {
77         banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
78       },
79       build: {
80         src: [
81             // These are concatenated in order in the final build file.
82             // The order is important.
83             'build/js/jquery.min.js',
84             'build/js/angular.min.js',
85             'build/js/angular-route.min.js',
86             'build/js/ui-bootstrap.min.js',
87             'build/js/ui-bootstrap-tpls.min.js',
88             'build/js/hotkeys.min.js',
89             // NOTE: OpenSRF must be installed
90             '/openils/lib/javascript/JSON_v1.js',
91             '/openils/lib/javascript/opensrf.js',
92             '/openils/lib/javascript/opensrf_ws.js',
93             'services/core.js',
94             'services/strings.js',
95             'services/idl.js',
96             'services/event.js',
97             'services/net.js',
98             'services/auth.js',
99             'services/pcrud.js',
100             'services/env.js',
101             'services/org.js',
102             'services/startup.js',
103             'services/hatch.js',
104             'services/print.js',
105             'services/coresvc.js',
106             'services/navbar.js',
107             'services/statusbar.js',
108             'services/ui.js',
109             'services/date.js',
110         ],
111         dest: 'build/js/<%= pkg.name %>.<%= pkg.version %>.min.js'
112       }
113     },
114
115     // bare concat operation; useful for testing concat w/o minification
116     // to more easily detect if concat order is incorrect
117     concat: {
118       options: {
119        separator: ';',
120       }
121     },
122
123     exec : {
124
125       // Generate test/data/IDL2js.js for unit tests.
126       // note: the output of this script is *not* part of the final build.
127       idl2js : {
128         command : 'cd test/data && perl idl2js.pl',
129       },
130
131       // Remove the unit test IDL2js.js file.  We don't need it after testing
132       rmidl2js : {
133         command : 'rm test/data/IDL2js.js',
134       }
135     },
136
137     // unit tests configuration
138     karma : {
139       unit: {
140         configFile: 'test/karma.conf.js',
141         //background: true  // for now, visually babysit unit tests
142       }
143     }
144   };
145
146   // tell concat about our uglify build options (instead of repeating them)
147   config.concat.build = config.uglify.build;
148
149   // apply our configuration
150   grunt.initConfig(config);
151
152   // Load our modules
153   grunt.loadNpmTasks('grunt-contrib-uglify');
154   grunt.loadNpmTasks('grunt-contrib-concat');
155   grunt.loadNpmTasks('grunt-contrib-copy');
156   grunt.loadNpmTasks('grunt-contrib-cssmin');
157   grunt.loadNpmTasks('grunt-karma');
158   grunt.loadNpmTasks('grunt-exec');
159
160   // note: "grunt concat" is not requried 
161   grunt.registerTask('build', ['copy', 'cssmin', 'uglify']);
162
163   // test only, no minification
164   grunt.registerTask('test', ['copy', 'exec:idl2js', 'karma:unit', 'exec:rmidl2js']);
165
166   // note: "grunt concat" is not requried 
167   grunt.registerTask('all', ['test', 'cssmin', 'uglify']);
168
169 };
170
171 // vim: ts=2:sw=2:softtabstop=2