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

Use forward slashes in source maps #175

Merged
merged 1 commit into from
Mar 18, 2014
Merged
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
8 changes: 5 additions & 3 deletions tasks/lib/uglify.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ exports.init = function(grunt) {
var fileDir = path.dirname(file);
var sourceMapDir = path.dirname(options.generatedSourceMapName);
var relativePath = path.relative(sourceMapDir, fileDir);
var pathPrefix = relativePath ? (relativePath+path.sep) : "";
var pathPrefix = relativePath ? (relativePath+path.sep) : '';

file = pathPrefix + basename;

sourcesContent[file] = code;
// Convert paths to use forward slashes for sourcemap use in the browser
sourcesContent[file.replace(/\\/g, '/')] = code;
topLevel = UglifyJS.parse(code, {
filename: file,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be normalized too, otherwise the sources will contain backslashes.

toplevel: topLevel
Expand Down Expand Up @@ -110,7 +111,8 @@ exports.init = function(grunt) {

// Add the source map reference to the end of the file
if (options.sourceMap) {
min += "\n//# sourceMappingURL="+options.destToSourceMap;
// Set all paths to forward slashes for use in the browser
min += "\n//# sourceMappingURL="+options.destToSourceMap.replace(/\\/g, '/');
}

var result = {
Expand Down