CSS: jQuery#hide should always save display value
[jquery.git] / Gruntfile.js
blobea570f1fa431bfcc89d1c01aa222b2668a10197d
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                                 // 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/hiddenVisibleSelectors", "effects/animatedSelector" ]
46                                 }
47                         }
48                 },
49                 bowercopy: {
50                         options: {
51                                 clean: true
52                         },
53                         src: {
54                                 files: {
55                                         "src/sizzle/dist": "sizzle/dist",
56                                         "src/sizzle/test/data": "sizzle/test/data",
57                                         "src/sizzle/test/unit": "sizzle/test/unit",
58                                         "src/sizzle/test/index.html": "sizzle/test/index.html",
59                                         "src/sizzle/test/jquery.js": "sizzle/test/jquery.js"
60                                 }
61                         },
62                         tests: {
63                                 options: {
64                                         destPrefix: "test/libs"
65                                 },
66                                 files: {
67                                         "qunit": "qunit/qunit",
68                                         "require.js": "requirejs/require.js",
69                                         "sinon/fake_timers.js": "sinon/lib/sinon/util/fake_timers.js"
70                                 }
71                         }
72                 },
73                 jsonlint: {
74                         pkg: {
75                                 src: [ "package.json" ]
76                         },
78                         jscs: {
79                                 src: [ ".jscs.json" ]
80                         },
82                         bower: {
83                                 src: [ "bower.json" ]
84                         }
85                 },
86                 jshint: {
87                         all: {
88                                 src: [
89                                         "src/**/*.js", "Gruntfile.js", "test/**/*.js", "build/tasks/*",
90                                         "build/{bower-install,release-notes,release}.js"
91                                 ],
92                                 options: {
93                                         jshintrc: true
94                                 }
95                         },
96                         dist: {
97                                 src: "dist/jquery.js",
98                                 options: srcHintOptions
99                         }
100                 },
101                 jscs: {
102                         src: "src/**/*.js",
103                         gruntfile: "Gruntfile.js",
104                         tasks: "build/tasks/*.js"
105                 },
106                 testswarm: {
107                         tests: "ajax attributes callbacks core css data deferred dimensions effects event manipulation offset queue selector serialize support traversing Sizzle".split( " " )
108                 },
109                 watch: {
110                         files: [ "<%= jshint.all.src %>" ],
111                         tasks: "dev"
112                 },
113                 uglify: {
114                         all: {
115                                 files: {
116                                         "dist/jquery.min.js": [ "dist/jquery.js" ]
117                                 },
118                                 options: {
119                                         preserveComments: false,
120                                         sourceMap: "dist/jquery.min.map",
121                                         sourceMappingURL: "jquery.min.map",
122                                         report: "min",
123                                         beautify: {
124                                                 ascii_only: true
125                                         },
126                                         banner: "/*! jQuery v<%= pkg.version %> | " +
127                                                 "(c) 2005, <%= grunt.template.today('yyyy') %> jQuery Foundation, Inc. | " +
128                                                 "jquery.org/license */",
129                                         compress: {
130                                                 hoist_funs: false,
131                                                 loops: false,
132                                                 unused: false
133                                         }
134                                 }
135                         }
136                 }
137         });
139         // Load grunt tasks from NPM packages
140         require( "load-grunt-tasks" )( grunt );
142         // Integrate jQuery specific tasks
143         grunt.loadTasks( "build/tasks" );
145         // Alias bower to bowercopy
146         grunt.registerTask( "bower", "bowercopy" );
148         // Short list as a high frequency watch task
149         grunt.registerTask( "dev", [ "build:*:*", "jshint", "jscs" ] );
151         // Default grunt
152         grunt.registerTask( "default", [ "jsonlint", "dev", "uglify", "dist:*", "compare_size" ] );