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