normalize the base path as well as the filename for sourcemaps. Fixes #1736

This commit is contained in:
Luke Page
2013-12-17 23:06:51 +00:00
parent 117262df31
commit 381fb98fdf

View File

@@ -8,7 +8,9 @@
this._sourceMapFilename = options.sourceMapFilename;
this._outputFilename = options.outputFilename;
this._sourceMapURL = options.sourceMapURL;
this._sourceMapBasepath = options.sourceMapBasepath;
if (this._sourceMapBasepath) {
this._sourceMapBasepath = options.sourceMapBasepath.replace(/\\/g, '/');
}
this._sourceMapRootpath = options.sourceMapRootpath;
this._outputSourceFiles = options.outputSourceFiles;
this._sourceMapGeneratorConstructor = options.sourceMapGenerator || require("source-map").SourceMapGenerator;
@@ -22,13 +24,14 @@
};
tree.sourceMapOutput.prototype.normalizeFilename = function(filename) {
filename = filename.replace(/\\/g, '/');
if (this._sourceMapBasepath && filename.indexOf(this._sourceMapBasepath) === 0) {
filename = filename.substring(this._sourceMapBasepath.length);
if (filename.charAt(0) === '\\' || filename.charAt(0) === '/') {
filename = filename.substring(1);
}
filename = filename.substring(this._sourceMapBasepath.length);
if (filename.charAt(0) === '\\' || filename.charAt(0) === '/') {
filename = filename.substring(1);
}
}
return (this._sourceMapRootpath || "") + filename.replace(/\\/g, '/');
return (this._sourceMapRootpath || "") + filename;
};
tree.sourceMapOutput.prototype.add = function(chunk, fileInfo, index, mapLines) {