-
-
Notifications
You must be signed in to change notification settings - Fork 601
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
Places incorrect paths in extracted source maps for input that has relative sources #1225
Comments
Somehow, I think this all ties back into the fact that Webpack itself wants disk-based - i.e. filesystem - absolute paths in source map When said URLs are relative, they are relative to the generated file. Most external supplied source maps are relative, because that's the only way they can be portable. Assuming Webpack is not going to budge and fix this mess, a work-around is needed where source map sources are eventually made compatible with Webpack's counter-spec status quo. This is complicated for a few reasons, mostly because there's a lot of moving parts capable of influencing the source map for CSS: Both A custom loader module can be written to normalize any unfit source maps before they are offered to either of these loaders. However, specifically for It and |
PR welcome, maybe need fix in css loader first |
I'm now running a small experiment, using esprima and escodegen to parse the JS module output by Sofar, that seems to work well with the MiniCssExtractPlugin as well. If this holds up, I'll consider building up a pull request with a real fix. (There's some performance-related motivation there for me to provide an integrated fix. Because of course; using esprima for outside manipulation is not cheap. ;-) ) |
Anyway feel free to put here any information and feedback |
Partial fixed for latest css-loader/mini-css-extract-plugin/webpack versions. Just note:
|
Now you will have |
I want to move this issue to |
@rjgotten Do you have ideas how we can achieve this? |
Maybe just cop out? Introduce a rule that says the first candidate matching a given predicate test is passed on. It's situational, I think. So probably a user specified predicate/test regex or function is the better deal. Then rewrite the source-map to only contain those matching sources, in situations where multiple are provided. |
@rjgotten We can't rewrite source maps, PostCSS does it, we just provide |
Ah sorry, about the confusion there. I didn't mean "rewrite the source-map" as in creating a chained source map, which indeed is what PostCSS should be doing. Thinking further though: why is the presence of multiple |
We can pass to |
Oh; right. Now I get what the problem is. Sure; in that case just going with whatever is listed as the first entry in |
Yep, I am worried that some of the tools may be generating incorrect invalid order of |
Hi! I am new to webpack and css-loader, but I want to share my observations and hope it helps, but if its not relevant for this issue, please ignore it. thx. 😉
On Stackoverflow I can read the following about it:
I found no option to change the internal behaviour of css-loader from CJS towards ES6 modules. Btw. I removed |
Expected Behavior
When offered compiled CSS content backed by a source map where
sources
are relative URLs, extracts a.css
file with a source map that has correct path information. That is: thesources
are resolved againstthis.context
of the compiled CSS content, producing the correct source locations.Actual Behavior
When offered compiled CSS content backed by a source map where
sources
are relative URLs, extracts acss
file with a source map that has incorrect path information. Thesources
seem to be output as-is to be interpreted by debuggers and dev-tools as relative to the extracted CSS file. This produces incorrect source locations.Code
N/A
How Do We Reproduce?
Minimal repro case:
https://github.com/NetMatch/mini-css-extract-plugin-testcase
The text was updated successfully, but these errors were encountered: