This repository was archived by the owner on Mar 26, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Expand file tree Collapse file tree 2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -74,13 +74,18 @@ module.exports = function (grunt) {
74
74
var sourceMap = false ;
75
75
if ( ext === '.js' || ext === '.css' ) {
76
76
var map = file + '.map' ;
77
- resultPath += '.map' ;
77
+ var resultPathMap = resultPath + '.map' ;
78
78
if ( grunt . file . exists ( map ) ) {
79
79
if ( move ) {
80
- fs . renameSync ( map , resultPath ) ;
80
+ fs . renameSync ( map , resultPathMap ) ;
81
81
} else {
82
- grunt . file . copy ( map , resultPath ) ;
82
+ grunt . file . copy ( map , resultPathMap ) ;
83
83
}
84
+
85
+ // rewrite the sourceMappingURL in files
86
+ var fileContents = grunt . file . read ( resultPath , { encoding : 'utf8' } ) ;
87
+ var newSrcMap = fileContents . replace ( '//# sourceMappingURL=' + path . basename ( file ) + '.map' , '//# sourceMappingURL=' + path . basename ( resultPathMap ) ) ;
88
+ grunt . file . write ( resultPath , newSrcMap , { encoding : 'utf8' } ) ;
84
89
sourceMap = true ;
85
90
}
86
91
}
Original file line number Diff line number Diff line change @@ -46,6 +46,13 @@ it('should use same revision as .js source for the .map', function () {
46
46
assert ( revisioned === original ) ;
47
47
} ) ;
48
48
49
+ it ( 'should point the .js sourceMappingURL to the revisioned .map' , function ( ) {
50
+ var file = 'test/fixtures/math.js' ;
51
+ var map = 'math.6272e937.js.map' ;
52
+ var revisioned = fs . readFileSync ( hashes [ file ] , { encoding : 'utf8' } ) ;
53
+ assert ( revisioned . indexOf ( '//# sourceMappingURL=' + map ) !== - 1 ) ;
54
+ } ) ;
55
+
49
56
it ( 'should revision .js file ok without any .map' , function ( ) {
50
57
var file = 'test/fixtures/physics.js' ;
51
58
var original = fs . statSync ( file ) . size ;
You can’t perform that action at this time.
0 commit comments