Fix #14084: attach the test div to documentElement, not body.
[jquery.git] / Gruntfile.js
blobc8060dc2411a0cd90c837a52952b819c6b49159b
1 module.exports = function( grunt ) {
3         "use strict";
5         var gzip = require( "gzip-js" ),
6                 readOptionalJSON = function( filepath ) {
7                         var data = {};
8                         try {
9                                 data = grunt.file.readJSON( filepath );
10                         } catch(e) {}
11                         return data;
12                 },
13                 srcHintOptions = readOptionalJSON( "src/.jshintrc" );
15         // The concatenated file won't pass onevar
16         // But our modules can
17         delete srcHintOptions.onevar;
19         grunt.initConfig({
20                 pkg: grunt.file.readJSON("package.json"),
21                 dst: readOptionalJSON("dist/.destination.json"),
22                 compare_size: {
23                         files: [ "dist/jquery.js", "dist/jquery.min.js" ],
24                         options: {
25                                 compress: {
26                                         gz: function( contents ) {
27                                                 return gzip.zip( contents, {} ).length;
28                                         }
29                                 },
30                                 cache: "dist/.sizecache.json"
31                         }
32                 },
33                 build: {
34                         all: {
35                                 dest: "dist/jquery.js",
36                                 minimum: [
37                                         "core",
38                                         "selector"
39                                 ],
40                                 // Exclude specified modules if the module matching the key is removed
41                                 removeWith: {
42                                         ajax: [ "manipulation/_evalUrl" ],
43                                         callbacks: [ "deferred" ],
44                                         css: [ "effects", "dimensions", "offset" ],
45                                         sizzle: [ "css/hidden-visible-selectors", "effects/animated-selector" ]
46                                 }
47                         }
48                 },
49                 jsonlint: {
50                         pkg: {
51                                 src: [ "package.json" ]
52                         },
53                         bower: {
54                                 src: [ "bower.json" ]
55                         }
56                 },
57                 jshint: {
58                         dist: {
59                                 src: [ "dist/jquery.js" ],
60                                 options: srcHintOptions
61                         },
62                         grunt: {
63                                 src: [ "Gruntfile.js", "build/tasks/*" ],
64                                 options: {
65                                         jshintrc: ".jshintrc"
66                                 }
67                         },
68                         tests: {
69                                 src: [ "test/**/*.js" ],
70                                 options: {
71                                         jshintrc: "test/.jshintrc"
72                                 }
73                         }
74                 },
75                 testswarm: {
76                         tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing Sizzle".split(" ")
77                 },
78                 watch: {
79                         files: [ "<%= jshint.grunt.src %>", "<%= jshint.tests.src %>", "src/**/*.js" ],
80                         tasks: "dev"
81                 },
82                 "pre-uglify": {
83                         all: {
84                                 files: {
85                                         "dist/jquery.pre-min.js": [ "dist/jquery.js" ]
86                                 },
87                                 options: {
88                                         banner: "\n\n\n\n\n\n\n\n\n\n\n\n" + // banner line size must be preserved
89                                                 "/*! jQuery v<%= pkg.version %> | " +
90                                                 "(c) 2005, 2013 jQuery Foundation, Inc. | " +
91                                                 "jquery.org/license */\n"
92                                 }
93                         }
94                 },
95                 uglify: {
96                         all: {
97                                 files: {
98                                         "dist/jquery.min.js": [ "dist/jquery.pre-min.js" ]
99                                 },
100                                 options: {
101                                         // Keep our hard-coded banner
102                                         preserveComments: "some",
103                                         sourceMap: "dist/jquery.min.map",
104                                         sourceMappingURL: "jquery.min.map",
105                                         report: "min",
106                                         beautify: {
107                                                 ascii_only: true
108                                         },
109                                         compress: {
110                                                 hoist_funs: false,
111                                                 join_vars: false,
112                                                 loops: false,
113                                                 unused: false
114                                         }
115                                 }
116                         }
117                 },
118                 "post-uglify": {
119                         all: {
120                                 files: {
121                                         "dist/jquery.min.map.tmp": [ "dist/jquery.min.map" ],
122                                         "dist/jquery.min.js.tmp": [ "dist/jquery.min.js" ]
123                                 },
124                                 options: {
125                                         tempFiles: [ "dist/jquery.min.map.tmp", "dist/jquery.min.js.tmp", "dist/jquery.pre-min.js" ]
126                                 }
127                         }
128                 }
129         });
131         // Load grunt tasks from NPM packages
132         grunt.loadNpmTasks( "grunt-compare-size" );
133         grunt.loadNpmTasks( "grunt-git-authors" );
134         grunt.loadNpmTasks( "grunt-contrib-watch" );
135         grunt.loadNpmTasks( "grunt-contrib-jshint" );
136         grunt.loadNpmTasks( "grunt-contrib-uglify" );
137         grunt.loadNpmTasks( "grunt-jsonlint" );
139         // Integrate jQuery specific tasks
140         grunt.loadTasks( "build/tasks" );
142         // Short list as a high frequency watch task
143         grunt.registerTask( "dev", [ "build:*:*", "jshint" ] );
145         // Default grunt
146         grunt.registerTask( "default", [ "jsonlint", "dev", "pre-uglify", "uglify", "post-uglify", "dist:*", "compare_size" ] );