@@ -4,7 +4,8 @@ module.exports = function( grunt ) {
4
4
5
5
var distpaths = [
6
6
"dist/jquery.js" ,
7
- "dist/jquery.min.js"
7
+ "dist/jquery.min.js" ,
8
+ "dist/jquery.min.map"
8
9
] ,
9
10
readOptionalJSON = function ( filepath ) {
10
11
var data = { } ;
@@ -96,7 +97,7 @@ module.exports = function( grunt ) {
96
97
} ,
97
98
options : {
98
99
banner : "/*! jQuery v<%= pkg.version %> jquery.com | jquery.org/license */" ,
99
- sourceMap : "dist/ jquery.source-map.js " ,
100
+ sourceMap : "jquery.min.map " ,
100
101
beautify : {
101
102
ascii_only : true
102
103
}
@@ -220,7 +221,7 @@ module.exports = function( grunt ) {
220
221
221
222
grunt . util . spawn ( {
222
223
cmd : process . platform === "win32" ? "grunt.cmd" : "grunt" ,
223
- args : [ "build:*:*:" + modules , "uglify" ]
224
+ args : [ "build:*:*:" + modules , "uglify" , "dist" ]
224
225
} , function ( err , result ) {
225
226
if ( err ) {
226
227
grunt . verbose . error ( ) ;
@@ -387,7 +388,7 @@ module.exports = function( grunt ) {
387
388
grunt . log . writeln ( "File '" + name + "' created." ) ;
388
389
} ) ;
389
390
390
- // Allow custom dist file locations
391
+ // Process files for distribution
391
392
grunt . registerTask ( "dist" , function ( ) {
392
393
var flags , paths , stored ;
393
394
@@ -408,47 +409,43 @@ module.exports = function( grunt ) {
408
409
nonascii = false ;
409
410
410
411
distpaths . forEach ( function ( filename ) {
411
- var buf = fs . readFileSync ( filename , "utf8" ) ,
412
+ var text = fs . readFileSync ( filename , "utf8" ) ,
412
413
i , c ;
413
- if ( buf . length !== Buffer . byteLength ( buf , "utf8" ) ) {
414
+ if ( text . length !== Buffer . byteLength ( text , "utf8" ) ) {
414
415
grunt . log . writeln ( filename + ": Non-ASCII characters detected:" ) ;
415
- for ( i = 0 ; i < buf . length ; i ++ ) {
416
- c = buf . charCodeAt ( i ) ;
416
+ for ( i = 0 ; i < text . length ; i ++ ) {
417
+ c = text . charCodeAt ( i ) ;
417
418
if ( c > 127 ) {
418
419
grunt . log . writeln ( "- position " + i + ": " + c ) ;
419
- grunt . log . writeln ( "-- " + buf . substring ( i - 20 , i + 20 ) ) ;
420
+ grunt . log . writeln ( "-- " + text . substring ( i - 20 , i + 20 ) ) ;
420
421
nonascii = true ;
422
+ break ;
421
423
}
422
424
}
423
425
}
424
- } ) ;
425
- if ( nonascii ) {
426
- return false ;
427
- }
428
426
429
- // Proceed only if there are actual
430
- // paths to write to
431
- if ( paths . length ) {
432
-
433
- // 'distpaths' is declared at the top of the
434
- // module.exports function scope. It is an array
435
- // of default files that jQuery creates
436
- distpaths . forEach ( function ( filename ) {
437
- paths . forEach ( function ( path ) {
438
- var created ;
439
-
440
- if ( ! / \/ $ / . test ( path ) ) {
441
- path += "/" ;
442
- }
427
+ // Modify map so that it points to files in the same folder;
428
+ // see https://github.com/mishoo/UglifyJS2/issues/47
429
+ if ( / \. m a p $ / . test ( filename ) ) {
430
+ text = text . replace ( / " d i s t \/ / g, "\"" ) ;
431
+ fs . writeFileSync ( filename , text , "utf-8" ) ;
432
+ }
443
433
444
- created = path + filename . replace ( "dist/" , "" ) ;
434
+ // Optionally copy dist files to other locations
435
+ paths . forEach ( function ( path ) {
436
+ var created ;
445
437
446
- grunt . file . write ( created , grunt . file . read ( filename ) ) ;
438
+ if ( ! / \/ $ / . test ( path ) ) {
439
+ path += "/" ;
440
+ }
447
441
448
- grunt . log . writeln ( "File '" + created + "' created." ) ;
449
- } ) ;
442
+ created = path + filename . replace ( "dist/" , "" ) ;
443
+ grunt . file . write ( created , text ) ;
444
+ grunt . log . writeln ( "File '" + created + "' created." ) ;
450
445
} ) ;
451
- }
446
+ } ) ;
447
+
448
+ return ! nonascii ;
452
449
} ) ;
453
450
454
451
// Load grunt tasks from NPM packages
0 commit comments