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