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