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