Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix path issues with source maps #117

Merged
merged 1 commit into from
Feb 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* text=auto
/test/fixtures/* text eol=lf
10 changes: 8 additions & 2 deletions tasks/lib/sourcemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ exports.init = function(grunt) {
// prior sourcemap and return src with sourceMappingURL removed.
SourceMapConcatHelper.prototype.addlines = function(src, filename) {
var relativeFilename = path.relative(path.dirname(this.dest), filename);

// sourceMap path references are URLs, so ensure forward slashes are used for paths passed to sourcemap library
relativeFilename = relativeFilename.replace(/\\/g, '/');
var node;
if (
/\/\/[@#]\s+sourceMappingURL=(.+)/.test(src) ||
Expand All @@ -121,6 +122,8 @@ exports.init = function(grunt) {
// Consider the relative path from source files to new sourcemap.
var sourcePathToSourceMapPath =
path.relative(path.dirname(this.dest), path.dirname(sourceMapPath));
// sourceMap path references are URLs, so ensure forward slashes are used for paths passed to sourcemap library
sourcePathToSourceMapPath = sourcePathToSourceMapPath.replace(/\\/g, '/');
// Store the sourceMap so that it may later be consumed.
this.maps.push([
sourceMapConsumer, relativeFilename, sourcePathToSourceMapPath
Expand Down Expand Up @@ -170,8 +173,11 @@ exports.init = function(grunt) {

// Return a string for inline use or write the source map to disk.
SourceMapConcatHelper.prototype._write = function() {
// ensure we're using forward slashes, because these are URLs
var file = path.relative(path.dirname(this.dest), this.files.dest);
file = file.replace(/\\/g, '/');
var code_map = this.node.toStringWithSourceMap({
file: path.relative(path.dirname(this.dest), this.files.dest)
file: file
});
// Consume the new sourcemap.
var generator = SourceMapGenerator.fromSourceMap(
Expand Down