-
-
Notifications
You must be signed in to change notification settings - Fork 604
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
Source Maps generating wrong file paths #280
Comments
Just for reference: This is where the file name is created (https://github.com/webpack/webpack/blob/master/lib/ModuleFilenameHelpers.js#L60). In the current code the module name is used as absolute path although it is not absolute. |
Same problem here, I would like the Another thing that annoy me is the way the paths are built: the following code seems suspicious to me: if(p.indexOf("../") !== 0)
p = "./" + p;
return "/" + p; I don't really understand the purpose of the test, as the urls seems to be ok without it. |
Should be fixed, if problem still exists please comment here #652 Thanks! |
When creating source maps with the CSS loader the file paths that are generated are wrong and don't follow the format which is used for JavaScript files.
CSS Loader defines a sourceRoot (
webpack://
) for the source map. Additionallywebpack://
is added a second time within theSourceMapDevToolPlugin
when the file names are generated usingModuleFilenameHelpers
. This finally results in this file path for the css file:'webpack:///webpack:///components/Test.css'
See this simple Example:
with
Test.js
:and
app.js
:and
webpack.config.js
:If you skip into the source map creation you can see that
moduleFileNames
inSourceMapDevToolPlugin
is correct for the JS files:However, if you look at the
moduleFileNames
for the source map from the CSS Loader you get:This is obviously wrong. I would expect the same path that was generated for the JS files.
While digging a little bit deeper into it I found out that the JS source maps that are processed always contain the absolute path to the JS file and an empty
sourceRoot
property.This could be easily changed in the loader. Just return the absolute path and don't pass a
sourceRoot
property.By doing this
moduleFileNames
now contains the correct path.The source maps that are generated by this change are correct and work as expected. I have not yet submitted a pull request because I first wanted to check with you if this change might have any other implications that I am not aware of.
This might also help to fix #194
The text was updated successfully, but these errors were encountered: