You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 28, 2026. It is now read-only.
Weird source map paths when used together with sass-loader #652
Do you want to request a feature or report a bug?
Bug report
What is the current behavior?
Wrong source map/resource paths using css-loader together with sass-loader as shown below:
Examples of source map paths using the plugin
The actual app.scss path is ./src/styles/app.scss
However the source map path for the file becomes ./src/styles/src/styles/app.scss and the absolute resource path: C:/Users/m51n/source/repos/source-map-path/src/styles/src/styles/app.scss (does not exist)
If the current behavior is a bug, please provide the steps to reproduce.
I've created a sample project here-- using the source map example from the sass-loader docs and code from the extract-text-webpack-plugin docs here
With the sample project above I used devtool: "inline-source-map".
What is the expected behavior?
Expected source map path returned by the plugin in this case would be ./src/styles/app.scss and absolute resource path as it exist on disk: C:/Users/m51n/source/repos/source-map-path/src/styles/app.scss
Came upon the same today with having duplicate-ish paths in sourcemaps.
Here's the relevant loaders in my config (no ExtractTextPlugin and devtool as source-map):
To me it seems like sass-loader uses the style file path relative to the current working directory and css-loader uses that same path as just a filename (rather than considering it a proper path?) and prepends the absolute path of the directory where the style file is imported from (regardless if it's by another style file or javascript)?
As a quick example, two files: /cwd/src/styles/core.scss /cwd/src/components/bla/styles.scss
Both will be imported by another file within /cwd/src/components/bla.
Sourcemap for core.scss will have the path: /cwd/src/components/bla/src/styles/core.scss
Sourcemap for styles.scss will have the path: /cwd/src/components/bla/src/components/bla/styles.scss
I haven't been able to fix it, but I've done some digging and will share what I have found in hopes of it being useful to someone who has more time to put into it.
/*202*/pipeline.process(inputSource,{/*203*/// we need a prefix to avoid path rewriting of PostCSS/*204*/from: "/css-loader!"+options.from,/*205*/to: options.to,/*206*/map: options.sourceMap ? {/*207*/prev: inputMap,/*208*/sourcesContent: true,/*209*/inline: false,/*210*/annotation: false/*211*/} : null/*212*/}).then(function(result){
Thanks @evilebottnawi - Since I haven't touched this since August, it will take me some time to get caught up / merge in changes that have come in since then. I will start with sass-loaderper my prior comment. I may be a bit slow on the update as there is a lot going on personally and professionally right now, but I will try to have an update for you by the end of the month.
extract-text-webpack-plugin is irrelevant for my case, since it's happening in develop mode with HMR, where style-loader and no extract plugins are being used (I use mini-css-extract-plugin anyway).
I think this problem only affects Windows users, which might be why it's flown under the radar for so long.
@npetruzzelli maybe i can help if you provide minimum reproducible test repo, i am already working on 2 version (you can look progress in master branch)
There, I've included a link to the fork and am in the process of merging in updates to the master branch. Once I have tests working, I will create a minimal, reproducible test repo (separate from the fork).
Master still has version 1.x according to it's package.json file. If you intended for me to look at progress for 2.x in the next branch, I do not have permission to view that. I'm going to guess you want me to work from master, can you confirm that?
Activity
dcatoday commentedon Jan 3, 2018
Hi I am seeing an issue using ~paths. The path is returned without any deliminating /'s in the url.
Songworks commentedon Jan 10, 2018
Came upon the same today with having duplicate-ish paths in sourcemaps.
Here's the relevant loaders in my config (no ExtractTextPlugin and devtool as source-map):
To me it seems like
sass-loaderuses the style file path relative to the current working directory andcss-loaderuses that same path as just a filename (rather than considering it a proper path?) and prepends the absolute path of the directory where the style file is imported from (regardless if it's by another style file or javascript)?As a quick example, two files:
/cwd/src/styles/core.scss/cwd/src/components/bla/styles.scssBoth will be imported by another file within
/cwd/src/components/bla.Sourcemap for core.scss will have the path:
/cwd/src/components/bla/src/styles/core.scssSourcemap for styles.scss will have the path:
/cwd/src/components/bla/src/components/bla/styles.scsswoldner commentedon Jan 10, 2018
@Songworks see webpack/sass-loader#529
@evilebottnawi promised that he would have a look in the near future 🔎
alexander-akait commentedon Jan 12, 2018
Just for information - reproducible test repo https://github.com/jwldnr/extract-text-issue
mattmewton commentedon Jan 19, 2018
I'm having this issue as well. Any update as to when it will be resolved?
woldner commentedon Feb 12, 2018
ping @evilebottnawi
alexander-akait commentedon Feb 12, 2018
@jwldnr sorry for delay, don't have time for this right now, PR welcome 👍
alexander-akait commentedon Feb 15, 2018
Feel free to PR if somebody have time
woldner commentedon Feb 15, 2018
Understood 👍🏼
vlad-ivanov-d commentedon Apr 18, 2018
Hey guys, do you have any progress/plans on this issue?
npetruzzelli commentedon Apr 19, 2018
I haven't been able to fix it, but I've done some digging and will share what I have found in hopes of it being useful to someone who has more time to put into it.
In comment webpack/sass-loader#484 (comment)
A deleted user claimed to have fixed the issue by editing what was line number 198 at the time:
https://github.com/webpack-contrib/css-loader/blob/v0.28.4/lib/processCss.js#L198
So all that was done was the prefix was removed.
As of this writing, the line has changed to 204:
https://github.com/webpack-contrib/css-loader/blob/v0.28.11/lib/processCss.js#L204
This code first appears in commit:
09bd206
as posted by @sokra to fix issue #154
Before this commit, sources looked something like this:

This occured in version
0.19.xso the first release that saw this go into effect was0.20.0:https://github.com/webpack-contrib/css-loader/blob/v0.20.0/lib/processCss.js#L167
It looks like if the
fromattribute may need more work, then the rest of it may fall into place.22 remaining items
npetruzzelli commentedon Nov 7, 2018
Thanks @evilebottnawi - Since I haven't touched this since August, it will take me some time to get caught up / merge in changes that have come in since then. I will start with
sass-loaderper my prior comment. I may be a bit slow on the update as there is a lot going on personally and professionally right now, but I will try to have an update for you by the end of the month.alexander-akait commentedon Nov 7, 2018
@npetruzzelli thanks for any helping 👍
Nettsentrisk commentedon Nov 8, 2018
extract-text-webpack-plugin is irrelevant for my case, since it's happening in develop mode with HMR, where style-loader and no extract plugins are being used (I use mini-css-extract-plugin anyway).
I think this problem only affects Windows users, which might be why it's flown under the radar for so long.
tenebrius commentedon Nov 14, 2018
Any progress or workaround guys?
alexander-akait commentedon Nov 14, 2018
@tenebrius Pr welcome
npetruzzelli commentedon Nov 28, 2018
@evilebottnawi - A lot of the hectic stuff has passed. I plan to resume work on it shortly. I am sorry for the delay.
alexander-akait commentedon Nov 28, 2018
@npetruzzelli maybe i can help if you provide minimum reproducible test repo, i am already working on
2version (you can look progress in master branch)npetruzzelli commentedon Nov 30, 2018
@evilebottnawi - I'll continue with comments in the PR: #753
There, I've included a link to the fork and am in the process of merging in updates to the master branch. Once I have tests working, I will create a minimal, reproducible test repo (separate from the fork).
Master still has version 1.x according to it's
package.jsonfile. If you intended for me to look at progress for 2.x in thenextbranch, I do not have permission to view that. I'm going to guess you want me to work frommaster, can you confirm that?alexander-akait commentedon Nov 30, 2018
@npetruzzelli use master branch 👍
Chris-Kim commentedon Dec 19, 2018
For me, this issue is resolved by upgrading
css-loaderto 2.x.xalexander-akait commentedon Mar 5, 2019
Other example https://github.com/kyle-ssg/sass-loader-bug
alexander-akait commentedon Mar 6, 2019
Find solution and problem, will be solved and released today