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