Offset: Fix .offset() to correctly work with ShadowDOM
[jquery.git] / Gruntfile.js
blobcb21a4fdfb799c3d6b02c46126ed0bda359028a3
1 module.exports = function( grunt ) {
2         "use strict";
4         function readOptionalJSON( filepath ) {
5                 var data = {};
6                 try {
7                         data = grunt.file.readJSON( filepath );
8                 } catch ( e ) {}
9                 return data;
10         }
12         var gzip = require( "gzip-js" ),
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: "build/.sizecache.json"
31                         }
32                 },
33                 build: {
34                         all: {
35                                 dest: "dist/jquery.js",
36                                 minimum: [
37                                         "core",
38                                         "selector"
39                                 ],
40                                 removeWith: {
41                                         ajax: [ "manipulation/_evalUrl", "event/ajax" ],
42                                         callbacks: [ "deferred" ],
43                                         css: [ "effects", "dimensions", "offset" ]
44                                 }
45                         }
46                 },
47                 npmcopy: {
48                         all: {
49                                 options: {
50                                         destPrefix: "external"
51                                 },
52                                 files: {
53                                         "sizzle/dist": "sizzle/dist",
54                                         "sizzle/LICENSE.txt": "sizzle/LICENSE.txt",
56                                         "npo/npo.js": "native-promise-only/npo.js",
58                                         "qunit/qunit.js": "qunitjs/qunit/qunit.js",
59                                         "qunit/qunit.css": "qunitjs/qunit/qunit.css",
60                                         "qunit/LICENSE.txt": "qunitjs/LICENSE.txt",
62                                         "requirejs/require.js": "requirejs/require.js",
64                                         "sinon/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js",
65                                         "sinon/timers_ie.js": "sinon/lib/sinon/util/timers_ie.js",
66                                         "sinon/LICENSE.txt": "sinon/LICENSE"
67                                 }
68                         }
69                 },
70                 jsonlint: {
71                         pkg: {
72                                 src: [ "package.json" ]
73                         },
75                         bower: {
76                                 src: [ "bower.json" ]
77                         }
78                 },
79                 jshint: {
80                         all: {
81                                 src: [
82                                         "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/**/*.js"
83                                 ],
84                                 options: {
85                                         jshintrc: true
86                                 }
87                         },
88                         dist: {
89                                 src: "dist/jquery.js",
90                                 options: srcHintOptions
91                         }
92                 },
93                 jscs: {
94                         src: "src/**/*.js",
95                         gruntfile: "Gruntfile.js",
97                         // Right now, check only test helpers
98                         test: [ "test/data/testrunner.js" ],
99                         release: [ "build/*.js", "!build/release-notes.js" ],
100                         tasks: "build/tasks/*.js"
101                 },
102                 testswarm: {
103                         tests: [
104                                 "ajax",
105                                 "attributes",
106                                 "callbacks",
107                                 "core",
108                                 "css",
109                                 "data",
110                                 "deferred",
111                                 "dimensions",
112                                 "effects",
113                                 "event",
114                                 "manipulation",
115                                 "offset",
116                                 "queue",
117                                 "selector",
118                                 "serialize",
119                                 "support",
120                                 "traversing"
121                         ]
122                 },
123                 watch: {
124                         files: [ "<%= jshint.all.src %>" ],
125                         tasks: [ "dev" ]
126                 },
127                 uglify: {
128                         all: {
129                                 files: {
130                                         "dist/jquery.min.js": [ "dist/jquery.js" ]
131                                 },
132                                 options: {
133                                         preserveComments: false,
134                                         sourceMap: true,
135                                         sourceMapName: "dist/jquery.min.map",
136                                         report: "min",
137                                         beautify: {
138                                                 "ascii_only": true
139                                         },
140                                         banner: "/*! jQuery Compat v<%= pkg.version %> | " +
141                                                 "(c) jQuery Foundation | jquery.org/license */",
142                                         compress: {
143                                                 "hoist_funs": false,
144                                                 loops: false,
145                                                 unused: false
146                                         }
147                                 }
148                         }
149                 }
150         });
152         // Load grunt tasks from NPM packages
153         require( "load-grunt-tasks" )( grunt );
155         // Integrate jQuery specific tasks
156         grunt.loadTasks( "build/tasks" );
158         grunt.registerTask( "lint", [ "jsonlint", "jshint", "jscs" ] );
160         // Only defined for master at this time, but kept for cross-branch consistency
161         grunt.registerTask( "test_fast", [] );
163         // gh-2133 TODO: cherry-pick 76df9e4e389d80bff410a9e5f08b848de1d21a2f for promises-aplus-tests
164         grunt.registerTask( "test", [ "test_fast"/*, "promises-aplus-tests"*/ ] );
166         // Short list as a high frequency watch task
167         grunt.registerTask( "dev", [ "build:*:*", "lint", "uglify", "remove_map_comment", "dist:*" ] );
169         grunt.registerTask( "default", [ "dev", "test_fast", "compare_size" ] );