Custom builds: Fix source folder location now that build.js is in the tasks folder
[jquery.git] / Gruntfile.js
blob6f75d39257b46dac49e0e5a4db7d4195438d056b
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" + // banner line size must be preserved
89                                                 "/*! jQuery v<%= pkg.version %> | " +
90                                                 "(c) 2005, 2013 jQuery Foundation, Inc. | " +
91                                                 "jquery.org/license\n" +
92                                                 "//@ sourceMappingURL=jquery.min.map\n" +
93                                                 "*/\n"
94                                 }
95                         }
96                 },
97                 uglify: {
98                         all: {
99                                 files: {
100                                         "dist/jquery.min.js": [ "dist/jquery.pre-min.js" ]
101                                 },
102                                 options: {
103                                         // Keep our hard-coded banner
104                                         preserveComments: "some",
105                                         sourceMap: "dist/jquery.min.map",
106                                         sourceMappingURL: "jquery.min.map",
107                                         report: "min",
108                                         beautify: {
109                                                 ascii_only: true
110                                         },
111                                         compress: {
112                                                 hoist_funs: false,
113                                                 join_vars: false,
114                                                 loops: false,
115                                                 unused: false
116                                         }
117                                 }
118                         }
119                 },
120                 "post-uglify": {
121                         all: {
122                                 files: {
123                                         "dist/jquery.min.map.tmp": [ "dist/jquery.min.map" ],
124                                         "dist/jquery.min.js.tmp": [ "dist/jquery.min.js" ]
125                                 },
126                                 options: {
127                                         tempFiles: [ "dist/jquery.min.map.tmp", "dist/jquery.min.js.tmp", "dist/jquery.pre-min.js" ]
128                                 }
129                         }
130                 }
131         });
133         // Load grunt tasks from NPM packages
134         grunt.loadNpmTasks( "grunt-compare-size" );
135         grunt.loadNpmTasks( "grunt-git-authors" );
136         grunt.loadNpmTasks( "grunt-contrib-watch" );
137         grunt.loadNpmTasks( "grunt-contrib-jshint" );
138         grunt.loadNpmTasks( "grunt-contrib-uglify" );
139         grunt.loadNpmTasks( "grunt-jsonlint" );
141         // Integrate jQuery specific tasks
142         grunt.loadTasks( "build/tasks" );
144         // Short list as a high frequency watch task
145         grunt.registerTask( "dev", [ "build:*:*", "jshint" ] );
147         // Default grunt
148         grunt.registerTask( "default", [ "jsonlint", "dev", "pre-uglify", "uglify", "post-uglify", "dist:*", "compare_size" ] );