forked from jquery-archive/jquery-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grunt.js
208 lines (170 loc) · 5.07 KB
/
grunt.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
var path = require( 'path' ), fs = require( 'fs' );
module.exports = function( grunt ) {
var dirs, names, min = {}, cssmin = {},
theme, rootFile, structureFile, themeFile,
verOfficial, suffix;
dirs = {
output: 'compiled',
temp: 'tmp'
};
verOfficial = grunt.file.read( 'version.txt' ).replace(/\n/, '');
suffix = process.env.IS_DEPLOY_TARGET === "true" ? "-" + verOfficial : "";
names= {
base: 'jquery.mobile' + suffix,
// this will change for the deploy target to include version information
root: 'jquery.mobile' + suffix,
structure: 'jquery.mobile.structure' + suffix,
theme: 'jquery.mobile.theme' + suffix
};
function outputPath( name ){
return path.join( dirs.output, name );
}
rootFile = outputPath( names.root );
structureFile = outputPath( names.structure );
themeFile = outputPath( names.theme );
// TODO again, I'd like to use grunt params but I'm not sure
// how to get that working with a custom task with deps
theme = process.env.THEME || 'default';
// Project configuration.
grunt.config.init({
jshint: {
options: {
curly: true,
eqeqeq: true,
// (function(){})() seems acceptable
immed: false,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
jQuery: true,
"$": true,
// qunit globals
// TODO would be nice to confine these to test files
module: true,
ok: true,
test: true,
asyncTest: true,
same: true,
start: true,
stop: true,
expect: true,
// require js global
define: true,
require: true
}
},
// TODO add test files here once we can specify different configs for
// different globs
lint: {
files: [ 'js/**/*.mobile.*.js', 'js/*/*.js' ]
},
// NOTE these configuration settings are used _after_ compilation has taken place
// using requirejs. Thus the .compiled extensions. The exception being the theme concat
concat: {
js: {
src: [ '<banner:global.ver.header>', rootFile + '.compiled.js' ],
dest: rootFile + '.js'
},
structure: {
src: [ '<banner:global.ver.header>', structureFile + '.compiled.css' ],
dest: structureFile + '.css'
},
regular: {
src: [ '<banner:global.ver.header>', rootFile + '.compiled.css' ],
dest: rootFile + '.css'
},
theme: {
src: [
'<banner:global.ver.header>',
'css/themes/' + theme + '/jquery.mobile.theme.css'
],
dest: themeFile + '.css'
}
},
// NOTE the keys are filenames which, being stored as variables requires that we use
// key based assignment. See below.
min: undefined,
cssmin: undefined,
// JS config, mostly the requirejs configuration
js: {
require: {
baseUrl: 'js',
name: 'jquery.mobile',
exclude: [
'jquery',
'depend',
'text',
'text!../version.txt'
],
out: rootFile + '.compiled.js',
pragmasOnSave: { jqmBuildExclude: true },
wrap: { startFile: 'build/wrap.start', endFile: 'build/wrap.end' },
findNestedDependencies: true,
skipModuleInsertion: true,
optimize: 'none'
}
},
// CSS config, mostly the requirejs configuration
css: {
theme: process.env.THEME || 'default',
themeFile: themeFile,
require: {
all: {
cssIn: 'css/themes/default/jquery.mobile.css',
optimizeCss: 'standard.keepComments.keepLines',
baseUrl: '.',
out: rootFile + '.compiled.css'
},
structure: {
cssIn: 'css/structure/jquery.mobile.structure.css',
out: structureFile + '.compiled.css'
}
}
},
global: {
dirs: dirs,
names: names,
files: {
license: 'LICENSE-INFO.txt'
},
// other version information is added via the asyncConfig helper that
// depends on git commands (eg ver.min, ver.header)
ver: {
official: verOfficial,
min: '/*! jQuery Mobile v<%= build_sha %> jquerymobile.com | jquery.org/license !*/',
gitLongSha: 'git log -1 --format=format:"Git Build: SHA1: %H <> Date: %cd"',
gitShortSha: 'git log -1 --format=format:"%H"'
},
shas: {}
}
});
// MIN configuration
min[ rootFile + '.min.js' ] = [ "<banner:global.ver.min>", rootFile + '.js' ];
grunt.config.set( 'min', min );
// CSSMIN configuration
cssmin[ rootFile + '.min.css' ] = [ "<banner:global.ver.min>", rootFile + '.css' ];
cssmin[ structureFile + '.min.css' ] = [ "<banner:global.ver.min>", structureFile + '.css' ];
cssmin[ themeFile + '.min.css' ] = [ "<banner:global.ver.min>", themeFile + '.css' ];
grunt.config.set( 'cssmin', cssmin );
// set the default task.
grunt.registerTask('default', 'lint');
// csslint and cssmin tasks
grunt.loadNpmTasks( "grunt-css" );
// authors task
grunt.loadNpmTasks( "grunt-git-authors" );
grunt.loadNpmTasks( "grunt-junit" );
// A convenient task alias.
grunt.registerTask('test', 'config:test:pages config:test junit');
// Ease of use aliases for users who want the zip and docs
grunt.registerTask('docs', 'js css legacy_tasks:docs');
grunt.registerTask('zip', 'js css legacy_tasks:zip');
// load the project's default tasks
grunt.loadTasks( 'build/tasks');
};