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