46
46
47
47
// minified files
48
48
minify = {
49
- "dist/jquery-ui.min.js" : [ "<banner:meta.bannerAll>" , "dist/jquery-ui.js" ] ,
50
- "dist/i18n/jquery-ui-i18n.min.js" : [ "<banner:meta.bannerI18n>" , "dist/i18n/jquery-ui-i18n.js" ]
49
+ options : {
50
+ preserveComments : false
51
+ } ,
52
+ main : {
53
+ options : {
54
+ banner : createBanner ( uiFiles )
55
+ } ,
56
+ files : {
57
+ "dist/jquery-ui.min.js" : "dist/jquery-ui.js"
58
+ }
59
+ } ,
60
+ i18n : {
61
+ options : {
62
+ banner : createBanner ( allI18nFiles )
63
+ } ,
64
+ files : {
65
+ "dist/i18n/jquery-ui-i18n.min.js" : "dist/i18n/jquery-ui-i18n.js"
66
+ }
67
+ }
51
68
} ,
52
69
53
70
minifyCSS = {
54
- "dist/jquery-ui.min.css" : "dist/jquery-ui.css"
71
+ options : {
72
+ keepSpecialComments : 0
73
+ } ,
74
+ main : {
75
+ options : {
76
+ keepSpecialComments : '*'
77
+ } ,
78
+ src : "dist/jquery-ui.css" ,
79
+ dest : "dist/jquery-ui.min.css"
80
+ }
55
81
} ,
56
82
57
83
compareFiles = {
58
- all : [
84
+ files : [
59
85
"dist/jquery-ui.js" ,
60
86
"dist/jquery-ui.min.js"
61
87
]
@@ -66,84 +92,95 @@ function mapMinFile( file ) {
66
92
}
67
93
68
94
uiFiles . concat ( allI18nFiles ) . forEach ( function ( file ) {
69
- minify [ mapMinFile ( file ) ] = [ "<banner>" , file ] ;
95
+ minify [ file ] = {
96
+ options : {
97
+ banner : createBanner ( )
98
+ } ,
99
+ files : { }
100
+ } ;
101
+ minify [ file ] . files [ mapMinFile ( file ) ] = file ;
70
102
} ) ;
71
103
72
104
cssFiles . forEach ( function ( file ) {
73
- minifyCSS [ "dist/" + file . replace ( / \. c s s $ / , ".min.css" ) . replace ( / t h e m e s \/ b a s e \/ / , "themes/base/minified/" ) ] = [ "<banner>" , "<strip_all_banners:" + file + ">" ] ;
105
+ minifyCSS [ file ] = {
106
+ options : {
107
+ banner : createBanner ( )
108
+ } ,
109
+ src : file ,
110
+ dest : "dist/" + file . replace ( / \. c s s $ / , ".min.css" ) . replace ( / t h e m e s \/ b a s e \/ / , "themes/base/minified/" )
111
+ } ;
74
112
} ) ;
75
113
76
114
uiFiles . forEach ( function ( file ) {
115
+ // TODO this doesn't do anything until https://github.com/rwldrn/grunt-compare-size/issues/13
77
116
compareFiles [ file ] = [ file , mapMinFile ( file ) ] ;
78
117
} ) ;
79
118
80
119
// grunt plugins
120
+ grunt . loadNpmTasks ( "grunt-contrib-jshint" ) ;
121
+ grunt . loadNpmTasks ( "grunt-contrib-uglify" ) ;
122
+ grunt . loadNpmTasks ( "grunt-contrib-concat" ) ;
123
+ grunt . loadNpmTasks ( "grunt-contrib-qunit" ) ;
81
124
grunt . loadNpmTasks ( "grunt-css" ) ;
82
125
grunt . loadNpmTasks ( "grunt-html" ) ;
83
126
grunt . loadNpmTasks ( "grunt-compare-size" ) ;
84
- grunt . loadNpmTasks ( "grunt-junit" ) ;
85
127
grunt . loadNpmTasks ( "grunt-git-authors" ) ;
86
128
// local testswarm and build tasks
87
129
grunt . loadTasks ( "build/tasks" ) ;
88
130
89
- grunt . registerHelper ( "strip_all_banners" , function ( filepath ) {
90
- return grunt . file . read ( filepath ) . replace ( / ^ \s * \/ \* [ \s \S ] * ?\* \/ \s * / g, "" ) ;
91
- } ) ;
92
-
93
- function stripBanner ( files ) {
94
- return files . map ( function ( file ) {
95
- return "<strip_all_banners:" + file + ">" ;
96
- } ) ;
97
- }
98
-
99
131
function stripDirectory ( file ) {
100
- // TODO: we're receiving the directive, so we need to strip the trailing >
101
- // we should be receving a clean path without the directive
102
132
return file . replace ( / .+ \/ ( .+ ?) > ? $ / , "$1" ) ;
103
133
}
104
- // allow access from banner template
105
- global . stripDirectory = stripDirectory ;
106
134
107
135
function createBanner ( files ) {
108
136
// strip folders
109
137
var fileNames = files && files . map ( stripDirectory ) ;
110
138
return "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - " +
111
139
"<%= grunt.template.today('isoDate') %>\n" +
112
- "<%= pkg.homepage ? '* ' + pkg.homepage + '\n' : '' %>" +
113
- "* Includes: " + ( files ? fileNames . join ( ", " ) : "<%= stripDirectory(grunt.task.current.file.src[1]) %>" ) + "\n" +
140
+ "<%= pkg.homepage ? '* ' + pkg.homepage + '\\ n' : '' %>" +
141
+ ( files ? "* Includes: " + fileNames . join ( ", " ) + "\n" : "" ) +
114
142
"* Copyright <%= grunt.template.today('yyyy') %> <%= pkg.author.name %>;" +
115
- " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */" ;
143
+ " Licensed <%= _.pluck(pkg.licenses, 'type').join(', ') %> */\n " ;
116
144
}
117
145
118
146
grunt . initConfig ( {
119
- pkg : "<json: package.json>" ,
147
+ pkg : grunt . file . readJSON ( " package.json" ) ,
120
148
files : {
121
149
dist : "<%= pkg.name %>-<%= pkg.version %>" ,
122
150
cdn : "<%= pkg.name %>-<%= pkg.version %>-cdn" ,
123
151
themes : "<%= pkg.name %>-themes-<%= pkg.version %>"
124
152
} ,
125
- meta : {
126
- banner : createBanner ( ) ,
127
- bannerAll : createBanner ( uiFiles ) ,
128
- bannerI18n : createBanner ( allI18nFiles ) ,
129
- bannerCSS : createBanner ( cssFiles )
130
- } ,
131
153
compare_size : compareFiles ,
132
154
concat : {
133
155
ui : {
134
- src : [ "<banner:meta.bannerAll>" , stripBanner ( uiFiles ) ] ,
156
+ options : {
157
+ banner : createBanner ( uiFiles ) ,
158
+ stripBanners : {
159
+ block : true
160
+ }
161
+ } ,
162
+ src : uiFiles ,
135
163
dest : "dist/jquery-ui.js"
136
164
} ,
137
165
i18n : {
138
- src : [ "<banner:meta.bannerI18n>" , allI18nFiles ] ,
166
+ options : {
167
+ banner : createBanner ( allI18nFiles )
168
+ } ,
169
+ src : allI18nFiles ,
139
170
dest : "dist/i18n/jquery-ui-i18n.js"
140
171
} ,
141
172
css : {
142
- src : [ "<banner:meta.bannerCSS>" , stripBanner ( cssFiles ) ] ,
173
+ options : {
174
+ banner : createBanner ( cssFiles ) ,
175
+ stripBanners : {
176
+ block : true
177
+ }
178
+ } ,
179
+ src : cssFiles ,
143
180
dest : "dist/jquery-ui.css"
144
181
}
145
182
} ,
146
- min : minify ,
183
+ uglify : minify ,
147
184
cssmin : minifyCSS ,
148
185
htmllint : {
149
186
// ignore files that contain invalid html, used only for ajax content testing
@@ -158,7 +195,7 @@ grunt.initConfig({
158
195
"jquery-*.js" ,
159
196
"MIT-LICENSE.txt" ,
160
197
"README.md" ,
161
- "grunt .js" ,
198
+ "Gruntfile .js" ,
162
199
"package.json" ,
163
200
"*.jquery.json" ,
164
201
"ui/**/*" ,
@@ -284,10 +321,31 @@ grunt.initConfig({
284
321
return ! ( / ( a l l | i n d e x | t e s t | d i a l o g | d i a l o g _ d e p r e c a t e d | t a b s | t o o l t i p ) \. h t m l $ / ) . test ( file ) ;
285
322
} )
286
323
} ,
287
- lint : {
288
- ui : "ui/*.js" ,
289
- grunt : [ "grunt.js" , "build/**/*.js" ] ,
290
- tests : "tests/unit/**/*.js"
324
+ jshint : {
325
+ ui : {
326
+ options : {
327
+ jshintrc : "ui/.jshintrc"
328
+ } ,
329
+ files : {
330
+ src : "ui/*.js"
331
+ }
332
+ } ,
333
+ grunt : {
334
+ options : {
335
+ jshintrc : ".jshintrc"
336
+ } ,
337
+ files : {
338
+ src : [ "Gruntfile.js" , "build/**/*.js" ]
339
+ }
340
+ } ,
341
+ tests : {
342
+ options : {
343
+ jshintrc : "tests/.jshintrc"
344
+ } ,
345
+ files : {
346
+ src : "tests/unit/**/*.js"
347
+ }
348
+ }
291
349
} ,
292
350
csslint : {
293
351
// nothing: []
@@ -307,39 +365,15 @@ grunt.initConfig({
307
365
"compatible-vendor-prefixes" : false
308
366
}
309
367
}
310
- } ,
311
- jshint : ( function ( ) {
312
- function parserc ( path ) {
313
- var rc = grunt . file . readJSON ( ( path || "" ) + ".jshintrc" ) ,
314
- settings = {
315
- options : rc ,
316
- globals : { }
317
- } ;
318
-
319
- ( rc . predef || [ ] ) . forEach ( function ( prop ) {
320
- settings . globals [ prop ] = true ;
321
- } ) ;
322
- delete rc . predef ;
323
-
324
- return settings ;
325
- }
326
-
327
- return {
328
- grunt : parserc ( ) ,
329
- ui : parserc ( "ui/" ) ,
330
- // TODO: `evil: true` is only for document.write() https://github.com/jshint/jshint/issues/519
331
- // TODO: don't create so many globals in tests
332
- tests : parserc ( "tests/" )
333
- } ;
334
- } ) ( )
368
+ }
335
369
} ) ;
336
370
337
- grunt . registerTask ( "default" , "lint csslint htmllint qunit" ) ;
338
- grunt . registerTask ( "sizer" , "concat:ui min:dist/jquery-ui.min.js compare_size:all" ) ;
339
- grunt . registerTask ( "sizer_all" , "concat:ui min compare_size" ) ;
340
- grunt . registerTask ( "build" , "concat min cssmin copy:dist_units_images" ) ;
341
- grunt . registerTask ( "release" , "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" ) ;
342
- grunt . registerTask ( "release_themes" , "release generate_themes copy:themes md5:themes zip:themes" ) ;
343
- grunt . registerTask ( "release_cdn" , "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" ) ;
371
+ grunt . registerTask ( "default" , [ "jshint" , " csslint" , " htmllint" , " qunit" ] ) ;
372
+ grunt . registerTask ( "sizer" , [ "concat:ui" , "uglify:main" , " compare_size:all" ] ) ;
373
+ grunt . registerTask ( "sizer_all" , [ "concat:ui" , "uglify" , " compare_size" ] ) ;
374
+ grunt . registerTask ( "build" , [ "concat" , "uglify" , " cssmin" , " copy:dist_units_images" ] ) ;
375
+ grunt . registerTask ( "release" , "clean build copy:dist copy:dist_min copy:dist_min_images copy:dist_css_min md5:dist zip:dist" . split ( " " ) ) ;
376
+ grunt . registerTask ( "release_themes" , "release generate_themes copy:themes md5:themes zip:themes" . split ( " " ) ) ;
377
+ grunt . registerTask ( "release_cdn" , "release_themes copy:cdn copy:cdn_min copy:cdn_i18n copy:cdn_i18n_min copy:cdn_min_images copy:cdn_themes md5:cdn zip:cdn" . split ( " " ) ) ;
344
378
345
379
} ;
0 commit comments