]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/web/js/ui/default/staff/Gruntfile.js
4bfb43316e4483740893746f54cdb67731f00288
[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-animate/angular-animate.min.js',
21             'bower_components/angular-animate/angular-animate.min.js.map',
22             'bower_components/angular-sanitize/angular-sanitize.min.js',
23             'bower_components/angular-sanitize/angular-sanitize.min.js.map',
24             'bower_components/angular-route/angular-route.min.js',
25             'bower_components/angular-route/angular-route.min.js.map',
26             'bower_components/angular-bootstrap/ui-bootstrap.min.js',
27             'bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
28             'bower_components/angular-hotkeys/build/hotkeys.min.js',
29             'bower_components/angular-file-saver/dist/angular-file-saver.bundle.min.js',
30             'bower_components/angular-location-update/angular-location-update.min.js',
31             'bower_components/angular-tree-control/angular-tree-control.js',
32             'bower_components/ngtoast/dist/ngToast.min.js',
33             'bower_components/jquery/dist/jquery.min.js',
34             'bower_components/angular-cookies/angular-cookies.min.js',
35             'bower_components/angular-cookies/angular-cookies.min.js.map'
36           ]
37         }]
38       },
39
40       css : {
41         files : [{
42           dest : 'build/css/',
43           flatten : true,
44           filter : 'isFile',
45           expand : true,
46           src : [
47             'bower_components/angular-hotkeys/build/hotkeys.min.css',
48             'bower_components/bootstrap/dist/css/bootstrap.min.css', 
49             'bower_components/ngtoast/dist/ngToast.min.css',
50             'bower_components/ngtoast/dist/ngToast-animations.min.css',
51             'bower_components/angular-tree-control/css/tree-control.css',
52             'bower_components/angular-tree-control/css/tree-control-attribute.css',
53           ]
54         }]
55       },
56
57       fonts : {
58         files : [{
59           dest : 'build/fonts/',
60           flatten : true,
61           filter : 'isFile',
62           expand : true,
63           src : [
64             'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.eot',
65             'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.svg',
66             'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf',
67             'bower_components/bootstrap/dist/fonts/glyphicons-halflings-regular.woff'
68           ]
69         }]
70       },
71
72       images : {
73         files : [{
74           dest : 'build/images/',
75           flatten : true,
76           filter : 'isFile',
77           expand : true,
78           src : [
79             'bower_components/angular-tree-control/images/sample.png',
80             'bower_components/angular-tree-control/images/node-opened-2.png',
81             'bower_components/angular-tree-control/images/folder.png',
82             'bower_components/angular-tree-control/images/node-closed.png',
83             'bower_components/angular-tree-control/images/node-closed-light.png',
84             'bower_components/angular-tree-control/images/node-opened.png',
85             'bower_components/angular-tree-control/images/node-opened-light.png',
86             'bower_components/angular-tree-control/images/folder-closed.png',
87             'bower_components/angular-tree-control/images/node-closed-2.png',
88             'bower_components/angular-tree-control/images/file.png'
89           ]
90         }]
91       }
92     },
93
94     // combine our CSS deps
95     // note: minification also supported, but not required (yet).
96     cssmin: {
97       combine: {
98         files: {
99           'build/css/evergreen-staff-client-deps.<%= pkg.version %>.min.css' : [
100             'build/css/hotkeys.min.css',
101             'build/css/bootstrap.min.css',
102             'build/css/ngToast.min.css',
103             'build/css/ngToast-animations.min.css',
104             'build/css/tree-control.css',
105             'build/css/tree-control-attribute.css',
106           ]
107         }
108       }
109     },
110
111     // concatenation + minification
112     uglify: {
113       options: {
114         banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
115       },
116       build: {
117         src: [
118             // These are concatenated in order in the final build file.
119             // The order is important.
120             'build/js/jquery.min.js',
121             'build/js/angular.min.js',
122             'build/js/angular-animate.min.js',
123             'build/js/angular-sanitize.min.js',
124             'build/js/angular-route.min.js',
125             'build/js/ui-bootstrap.min.js',
126             'build/js/ui-bootstrap-tpls.min.js',
127             'build/js/hotkeys.min.js',
128             'build/js/angular-tree-control.js',
129             'build/js/ngToast.min.js',
130             // NOTE: OpenSRF must be installed
131             '/openils/lib/javascript/JSON_v1.js',
132             '/openils/lib/javascript/opensrf.js',
133             '/openils/lib/javascript/opensrf_ws.js',
134             'services/core.js',
135             'services/strings.js',
136             'services/idl.js',
137             'services/event.js',
138             'services/net.js',
139             'services/auth.js',
140             'services/pcrud.js',
141             'services/env.js',
142             'services/org.js',
143             'services/startup.js',
144             'services/hatch.js',
145             'services/print.js',
146             'services/audio.js',
147             'services/coresvc.js',
148             'services/navbar.js',
149             'services/statusbar.js',
150             'services/ui.js',
151             'services/date.js',
152         ],
153         dest: 'build/js/<%= pkg.name %>.<%= pkg.version %>.min.js'
154       }
155     },
156
157     // bare concat operation; useful for testing concat w/o minification
158     // to more easily detect if concat order is incorrect
159     concat: {
160       options: {
161        separator: ';',
162       }
163     },
164
165     exec : {
166
167       // Generate test/data/IDL2js.js for unit tests.
168       // note: the output of this script is *not* part of the final build.
169       idl2js : {
170         command : 'cd test/data && perl idl2js.pl',
171       },
172
173       // Remove the unit test IDL2js.js file.  We don't need it after testing
174       rmidl2js : {
175         command : 'rm test/data/IDL2js.js',
176       }
177     },
178
179     // unit tests configuration
180     karma : {
181       unit: {
182         configFile: 'test/karma.conf.js',
183         //background: true  // for now, visually babysit unit tests
184       }
185     }
186   };
187
188   // tell concat about our uglify build options (instead of repeating them)
189   config.concat.build = config.uglify.build;
190
191   // apply our configuration
192   grunt.initConfig(config);
193
194   // Load our modules
195   grunt.loadNpmTasks('grunt-contrib-uglify');
196   grunt.loadNpmTasks('grunt-contrib-concat');
197   grunt.loadNpmTasks('grunt-contrib-copy');
198   grunt.loadNpmTasks('grunt-contrib-cssmin');
199   grunt.loadNpmTasks('grunt-karma');
200   grunt.loadNpmTasks('grunt-exec');
201
202   // note: "grunt concat" is not requried 
203   grunt.registerTask('build', ['copy', 'cssmin', 'uglify']);
204
205   // test only, no minification
206   grunt.registerTask('test', ['copy', 'exec:idl2js', 'karma:unit', 'exec:rmidl2js']);
207
208   // note: "grunt concat" is not requried 
209   grunt.registerTask('all', ['test', 'cssmin', 'uglify']);
210
211 };
212
213 // vim: ts=2:sw=2:softtabstop=2