2012-04-18 20:07:35 +00:00
|
|
|
module.exports = function( grunt ) {
|
2012-10-16 14:10:17 +00:00
|
|
|
"use strict";
|
|
|
|
|
2013-09-12 20:51:59 +00:00
|
|
|
function readOptionalJSON( filepath ) {
|
|
|
|
var data = {};
|
|
|
|
try {
|
|
|
|
data = grunt.file.readJSON( filepath );
|
2013-11-09 22:12:06 +00:00
|
|
|
} catch ( e ) {}
|
2013-09-12 20:51:59 +00:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2013-08-16 13:48:00 +00:00
|
|
|
var gzip = require( "gzip-js" ),
|
2013-07-11 16:52:07 +00:00
|
|
|
srcHintOptions = readOptionalJSON( "src/.jshintrc" );
|
2013-04-09 16:48:34 +00:00
|
|
|
|
|
|
|
// The concatenated file won't pass onevar
|
|
|
|
// But our modules can
|
|
|
|
delete srcHintOptions.onevar;
|
2012-04-18 20:07:35 +00:00
|
|
|
|
|
|
|
grunt.initConfig({
|
2013-11-09 22:12:06 +00:00
|
|
|
pkg: grunt.file.readJSON( "package.json" ),
|
|
|
|
dst: readOptionalJSON( "dist/.destination.json" ),
|
2012-04-18 20:07:35 +00:00
|
|
|
compare_size: {
|
2013-03-25 04:47:46 +00:00
|
|
|
files: [ "dist/jquery.js", "dist/jquery.min.js" ],
|
|
|
|
options: {
|
|
|
|
compress: {
|
|
|
|
gz: function( contents ) {
|
|
|
|
return gzip.zip( contents, {} ).length;
|
|
|
|
}
|
|
|
|
},
|
2013-11-10 21:34:46 +00:00
|
|
|
cache: "build/.sizecache.json"
|
2013-03-25 04:47:46 +00:00
|
|
|
}
|
2012-04-18 20:07:35 +00:00
|
|
|
},
|
|
|
|
build: {
|
2013-04-18 17:19:22 +00:00
|
|
|
all: {
|
2013-01-26 18:38:04 +00:00
|
|
|
dest: "dist/jquery.js",
|
2013-08-15 18:15:49 +00:00
|
|
|
minimum: [
|
|
|
|
"core",
|
|
|
|
"selector"
|
|
|
|
],
|
|
|
|
removeWith: {
|
2013-08-16 14:11:22 +00:00
|
|
|
ajax: [ "manipulation/_evalUrl" ],
|
2013-08-15 18:15:49 +00:00
|
|
|
callbacks: [ "deferred" ],
|
|
|
|
css: [ "effects", "dimensions", "offset" ]
|
|
|
|
}
|
2013-01-26 18:38:04 +00:00
|
|
|
}
|
2012-04-18 20:07:35 +00:00
|
|
|
},
|
2013-12-06 20:55:55 +00:00
|
|
|
bowercopy: {
|
|
|
|
options: {
|
|
|
|
clean: true
|
|
|
|
},
|
|
|
|
src: {
|
|
|
|
files: {
|
2014-01-13 21:37:42 +00:00
|
|
|
"src/sizzle/dist": "sizzle/dist",
|
|
|
|
"src/sizzle/test/data": "sizzle/test/data",
|
|
|
|
"src/sizzle/test/unit": "sizzle/test/unit",
|
|
|
|
"src/sizzle/test/index.html": "sizzle/test/index.html",
|
|
|
|
"src/sizzle/test/jquery.js": "sizzle/test/jquery.js"
|
2013-12-06 20:55:55 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
tests: {
|
2013-11-14 15:17:18 +00:00
|
|
|
options: {
|
2013-12-06 20:55:55 +00:00
|
|
|
destPrefix: "test/libs"
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
"qunit": "qunit/qunit",
|
2014-01-10 15:24:52 +00:00
|
|
|
"require.js": "requirejs/require.js",
|
2014-01-13 18:22:51 +00:00
|
|
|
"sinon/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js",
|
|
|
|
"sinon/timers_ie.js": "sinon/lib/sinon/util/timers_ie.js"
|
2013-11-14 15:17:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-07-19 13:53:57 +00:00
|
|
|
jsonlint: {
|
|
|
|
pkg: {
|
|
|
|
src: [ "package.json" ]
|
|
|
|
},
|
2013-09-12 20:51:59 +00:00
|
|
|
|
2013-07-19 13:53:57 +00:00
|
|
|
bower: {
|
|
|
|
src: [ "bower.json" ]
|
|
|
|
}
|
|
|
|
},
|
2012-12-19 04:02:50 +00:00
|
|
|
jshint: {
|
2013-12-18 14:23:27 +00:00
|
|
|
all: {
|
|
|
|
src: [
|
|
|
|
"src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/tasks/*",
|
|
|
|
"build/{bower-install,release-notes,release}.js"
|
|
|
|
],
|
2013-09-06 18:31:48 +00:00
|
|
|
options: {
|
2013-12-18 14:23:27 +00:00
|
|
|
jshintrc: true
|
2013-09-06 18:31:48 +00:00
|
|
|
}
|
|
|
|
},
|
2012-12-19 04:02:50 +00:00
|
|
|
dist: {
|
2013-09-12 20:51:59 +00:00
|
|
|
src: "dist/jquery.js",
|
2013-04-09 16:48:34 +00:00
|
|
|
options: srcHintOptions
|
2012-12-19 04:02:50 +00:00
|
|
|
}
|
2012-05-09 07:34:00 +00:00
|
|
|
},
|
2013-09-12 20:51:59 +00:00
|
|
|
jscs: {
|
2013-11-08 15:03:51 +00:00
|
|
|
src: "src/**/*.js",
|
|
|
|
gruntfile: "Gruntfile.js",
|
2014-02-18 16:32:17 +00:00
|
|
|
|
|
|
|
// Right know, check only test helpers
|
|
|
|
test: [ "test/data/testrunner.js", "test/data/testinit.js" ],
|
2013-11-08 15:03:51 +00:00
|
|
|
tasks: "build/tasks/*.js"
|
2013-09-12 20:51:59 +00:00
|
|
|
},
|
2012-12-13 01:19:18 +00:00
|
|
|
testswarm: {
|
2014-04-15 14:38:23 +00:00
|
|
|
tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing".split( " " )
|
2012-12-13 01:19:18 +00:00
|
|
|
},
|
2012-04-18 20:07:35 +00:00
|
|
|
watch: {
|
2013-12-20 23:38:57 +00:00
|
|
|
files: [ "<%= jshint.all.src %>" ],
|
2012-06-05 15:50:49 +00:00
|
|
|
tasks: "dev"
|
2012-04-18 20:07:35 +00:00
|
|
|
},
|
2012-10-11 13:38:44 +00:00
|
|
|
uglify: {
|
2012-12-19 04:02:50 +00:00
|
|
|
all: {
|
|
|
|
files: {
|
2013-11-09 22:12:06 +00:00
|
|
|
"dist/jquery.min.js": [ "dist/jquery.js" ]
|
2012-12-19 04:02:50 +00:00
|
|
|
},
|
|
|
|
options: {
|
2013-11-09 22:12:06 +00:00
|
|
|
preserveComments: false,
|
2012-12-22 21:23:27 +00:00
|
|
|
sourceMap: "dist/jquery.min.map",
|
2013-04-18 17:19:22 +00:00
|
|
|
sourceMappingURL: "jquery.min.map",
|
|
|
|
report: "min",
|
|
|
|
beautify: {
|
|
|
|
ascii_only: true
|
|
|
|
},
|
2013-11-09 22:12:06 +00:00
|
|
|
banner: "/*! jQuery v<%= pkg.version %> | " +
|
2014-01-10 01:51:21 +00:00
|
|
|
"(c) 2005, <%= grunt.template.today('yyyy') %> jQuery Foundation, Inc. | " +
|
2013-11-09 22:12:06 +00:00
|
|
|
"jquery.org/license */",
|
2013-01-29 00:04:58 +00:00
|
|
|
compress: {
|
2013-09-24 14:23:58 +00:00
|
|
|
hoist_funs: false,
|
2013-10-15 21:59:58 +00:00
|
|
|
loops: false,
|
|
|
|
unused: false
|
2012-12-19 04:02:50 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-11 13:38:44 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-18 20:07:35 +00:00
|
|
|
});
|
|
|
|
|
2012-12-19 04:02:50 +00:00
|
|
|
// Load grunt tasks from NPM packages
|
2013-10-25 18:02:04 +00:00
|
|
|
require( "load-grunt-tasks" )( grunt );
|
2013-08-16 13:48:00 +00:00
|
|
|
|
|
|
|
// Integrate jQuery specific tasks
|
|
|
|
grunt.loadTasks( "build/tasks" );
|
2012-12-19 04:02:50 +00:00
|
|
|
|
2013-12-06 20:55:55 +00:00
|
|
|
grunt.registerTask( "bower", "bowercopy" );
|
2014-02-18 16:34:49 +00:00
|
|
|
grunt.registerTask( "lint", [ "jshint", "jscs" ] );
|
2013-12-06 20:55:55 +00:00
|
|
|
|
2012-12-19 04:02:50 +00:00
|
|
|
// Short list as a high frequency watch task
|
2014-02-18 16:34:49 +00:00
|
|
|
grunt.registerTask( "dev", [ "build:*:*", "lint" ] );
|
2013-07-19 13:53:57 +00:00
|
|
|
|
|
|
|
// Default grunt
|
2013-11-09 22:12:06 +00:00
|
|
|
grunt.registerTask( "default", [ "jsonlint", "dev", "uglify", "dist:*", "compare_size" ] );
|
2012-04-18 20:07:35 +00:00
|
|
|
};
|