forked from jquery/jquery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grunt.js
159 lines (142 loc) · 3.45 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
/*global config:true, task:true*/
module.exports = function( grunt ) {
var task = grunt.task;
var file = grunt.file;
var utils = grunt.utils;
var log = grunt.log;
var verbose = grunt.verbose;
var fail = grunt.fail;
var option = grunt.option;
var config = grunt.config;
var template = grunt.template;
grunt.initConfig({
pkg: "<json:package.json>",
meta: {
banner: "/*! jQuery v@<%= pkg.version %> jquery.com | jquery.org/license */"
},
compare_size: {
files: [
"dist/jquery.js",
"dist/jquery.min.js"
]
},
selector: {
"src/selector.js": [
"src/sizzle-jquery.js",
"src/sizzle/sizzle.js"
]
},
build: {
"dist/jquery.js": [
"src/intro.js",
"src/core.js",
"src/callbacks.js",
"src/deferred.js",
"src/support.js",
"src/data.js",
"src/queue.js",
"src/attributes.js",
"src/event.js",
"src/selector.js",
"src/traversing.js",
"src/manipulation.js",
"src/css.js",
"src/ajax.js",
"src/ajax/jsonp.js",
"src/ajax/script.js",
"src/ajax/xhr.js",
"src/effects.js",
"src/offset.js",
"src/dimensions.js",
"src/exports.js",
"src/outro.js"
]
},
min: {
"dist/jquery.min.js": [ "<banner>", "dist/jquery.js" ]
},
lint: {
files: [ "grunt.js", "dist/jquery.js" ]
},
watch: {
files: "<config:lint.files>",
tasks: "concat lint"
},
jshint: {
options: {
evil: true,
browser: true,
wsh: true,
eqnull: true,
expr: true,
curly: true,
trailing: true,
undef: true,
smarttabs: true,
predef: [
"define",
"DOMParser",
"WebKitPoint",
"__dirname"
],
maxerr: 100
},
globals: {
jQuery: true,
global: true,
module: true,
exports: true,
require: true,
file: true,
log: true,
console: true
}
},
uglify: {}
});
// Default grunt.
grunt.registerTask( "default", "selector build lint min compare_size" );
grunt.loadNpmTasks("grunt-compare-size");
// Build src/selector.js
grunt.registerMultiTask( "selector", "Build src/selector.js", function() {
var name = this.file.dest,
files = this.file.src,
sizzle = {
api: file.read( files[0] ),
src: file.read( files[1] )
},
compiled;
// sizzle-jquery.js -> sizzle after "EXPOSE", replace window.Sizzle
compiled = sizzle.src.replace( "window.Sizzle = Sizzle;", sizzle.api );
verbose.write("Injected sizzle-jquery.js into sizzle.js");
// Write concatenated source to file
file.write( name, compiled );
// Fail task if errors were logged.
if ( this.errorCount ) {
return false;
}
// Otherwise, print a success message.
log.writeln( "File '" + name + "' created." );
});
// Special concat/build task to handle various jQuery build requirements
grunt.registerMultiTask( "build", "Concatenate source, embed date/version", function() {
// Concat specified files.
var compiled = "",
name = this.file.dest;
this.file.src.forEach(function( filepath ) {
compiled += file.read( filepath ).replace( /.function..jQuery...\{/g, "" ).replace( /\}...jQuery..;/g, "" );
});
// Embed Date
// Embed Version
compiled = compiled.replace( "@DATE", new Date() )
.replace( "@VERSION", config("pkg.version") );
// Write concatenated source to file
file.write( name, compiled );
// Fail task if errors were logged.
if ( this.errorCount ) {
return false;
}
// Otherwise, print a success message.
log.writeln( "File '" + name + "' created." );
});
};