-
Notifications
You must be signed in to change notification settings - Fork 3
/
Gruntfile.js
114 lines (103 loc) · 2.8 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*global module:false*/
module.exports = function(grunt) {
// Helper methods
function sub (str) {
return str.replace(/%s/g, LIBRARY_NAME);
}
function wrapModules (head, tail) {
return head.concat(MODULE_LIST).concat(tail);
}
var LIBRARY_NAME = 'ndeflibrary';
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Add your modules to this list
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
var MODULE_LIST = [
sub('src/%s.module.js'),
sub('src/submodule/%s.NdefAndroidAppRecord.js'),
sub('src/submodule/%s.NdefSocialRecord.js'),
sub('src/submodule/%s.NdefGeoRecord.js'),
sub('src/submodule/%s.NdefTelRecord.js'),
sub('src/submodule/%s.NdefUriRecord.js'),
sub('src/submodule/%s.NdefTextRecord.js'),
sub('src/submodule/%s.NdefRecord.js'),
sub('src/submodule/%s.NdefMessage.js')
];
var DIST_HEAD_LIST = [
sub('src/%s.intro.js'),
sub('src/%s.const.js'),
sub('src/%s.core.js')
];
var DEV_HEAD_LIST = [
sub('src/%s.intro.js'),
sub('src/%s.const.js'),
sub('src/%s.core.js')
];
var TAIL_LIST = [
sub('src/%s.init.js'),
sub('src/%s.outro.js')
];
// Gets inserted at the top of the generated files in dist/.
var BANNER = [
'/*! <%= pkg.name %> - v<%= pkg.version %> - ',
'<%= grunt.template.today("yyyy-mm-dd") %> - <%= pkg.author %> */\n'
].join('');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
options: {
banner: BANNER
},
src: wrapModules(DIST_HEAD_LIST, TAIL_LIST),
dest: sub('dist/%s.js')
},
dev: {
options: {
banner: BANNER
},
src: wrapModules(DEV_HEAD_LIST, TAIL_LIST),
dest: sub('dist/%s.js')
}
},
uglify: {
dist: {
files: (function () {
// Using an IIFE so that the destination property name can be
// created dynamically with sub().
var obj = {};
obj[sub('dist/%s.min.js')] = [sub('dist/%s.js')];
return obj;
} ())
},
options: {
banner: BANNER
}
},
qunit: {
files: ['test/qunit*.html']
},
jshint: {
all_files: [
'grunt.js',
sub('src/%s.!(intro|outro|const)*.js')
],
options: {
jshintrc: '.jshintrc'
}
}
});
grunt.registerTask('default', [
'jshint',
'build',
'qunit'
]);
grunt.registerTask('build', [
'concat:dist',
'uglify:dist',
'concat:dev'
]);
};