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.
sourceMap css does not function for background-image (maybe stylus-loader issue) #29
So this issue is bizarre and I hope I can make an example that does this.
I successful got sourceMaps to work with stylus-loader with { test: /\.styl$/, loader: 'style!css?sourceMap!stylus' }
However when ?sourceMap is enabled all our background url('whatever/sprite.png') no longer work. When the ?sourceMap is removed all is well.
I will make an example repo when I get the chance. Also let me know if this should be an issue on stylus-loader instead.
As for more info the css produced are identical except that sourcemap css is redirected via @import some url. The computed CSS reported by Chrome Debugger is identical, but using (Chrome Extension) CSSViewer reports different processed CSS. Which shows the missing sprite.
Also this problem exists in Firefox as well so I do not think it is a chrome issue.
changed the title [-]sourceMap css does not function for background-image[/-][+]sourceMap css does not function for background-image (maybe stylus-loader issue)[/+]on Dec 17, 2014
I just came across the same issue where background images from css don't work because of the paths, when using sourcemaps, css-loader and file-loader in dev mode with webpack-dev-server.
For now I've simply disabled sourcemaps, but was there a better fix? style-loader!css-loader?sourceMap was mentioned but this is exactly what's breaking for me.
Right I am using publicPath: 'http://localhost:9999/' but when I inspect the location of the background-image its chrome-devtools://devtools/public/img/ajax-loader.gif. The original path is /public/img/ajax-loader.gif
This still seems to be an issue. Using webpack v1.12.14, css-loader v0.23.1. When sourcemaps are on, background-images will not work. Setting output.publicPath to a full url does nothing to resolve the problem.
Reacted by hasc, Eugene Moroz, Dmitry, Tim Elfelt, Joacim de la Motte, Franklin Lee, Andrew Albright, zweicoder, Alex Zinkevych, Josh Wright and 8 more
I can confirm that setting output.publicPath to a full url fixed the problem for me. My webpack server is hosted on port 5000, my related chunk of config looks as follows:
Still facing this problem. I dont want to set an absolute URL like http://... So only thing i can do is to remove the sourceMap
I am having issues with this as well, hoping for a solution that doesn't involve setting an absolute url on publicPath. Webpack is pretty much useless as build tool in your development workflow if you cannot use source maps to understand what styles are needing to be adjusted when viewing an elements styling.
Reacted by Kuba Fibinger, Dušan Andrić, Henrik Raitasola, Chang Wang and Aliaksei Kislou
Only solution that worked for me was to use sourceMaps with extract-text-webpack-plugin to extract css to own file + change devtool from "eval-source-map" to "source-map".
Only problem now is that hot reload is veery slow because of high quality source maps. So this is viable only for staging or production environment :)
Activity
[-]sourceMap css does not function for background-image[/-][+]sourceMap css does not function for background-image (maybe stylus-loader issue)[/+]nmccready commentedon Dec 17, 2014
https://chrome.google.com/webstore/detail/cssviewer/ggfgijbpiheegefliciemofobhmofgce
sokra commentedon Dec 27, 2014
The problem is that DataUrls cannot download resources... (The stylesheet is embedded as DataUrl to append the SourceMap)
As workaround you could include every image as DataUrl (with the url-loader instead of the file-loader)...
I'll try to find a better solution...
nmccready commentedon Jan 13, 2015
Thank you.
sokra commentedon Apr 9, 2015
URL.createObjectURL+Blob+sourceMappingURLdoes work.nmccready commentedon Apr 9, 2015
Its been a while; how would this look in the config?
sokra commentedon Apr 9, 2015
style-loader!css-loader?sourceMaptimaschew commentedon Jun 19, 2015
we are using stylus-loader and all the
urlpaths are not resolved, if the stylus file was called via another module via~myModule.With this settings for the stylus-loader it's working:
?{"resolve url": true}kevinrenskers commentedon Jul 28, 2015
I just came across the same issue where background images from css don't work because of the paths, when using sourcemaps, css-loader and file-loader in dev mode with webpack-dev-server.
For now I've simply disabled sourcemaps, but was there a better fix?
style-loader!css-loader?sourceMapwas mentioned but this is exactly what's breaking for me.sokra commentedon Jul 28, 2015
I think a workaround is to use an absolute URL as
output.publicPath.nmccready commentedon Jul 30, 2015
#113 related; tried the pubicPath still didn't work.
nmccready commentedon Jul 30, 2015
This issue is also failing with fonts as well. They are being declared as they cannot be decoded in chrome or firefox. Oddly it works fine in safari.
nmccready commentedon Jul 30, 2015
webpack/style-loader#55
2 remaining items
tkiethanom commentedon Sep 18, 2015
Right I am using
publicPath: 'http://localhost:9999/'but when I inspect the location of the background-image itschrome-devtools://devtools/public/img/ajax-loader.gif. The original path is/public/img/ajax-loader.gifThis only happens when sourcemap is on.
AStaroverov commentedon Oct 6, 2015
for me too :(
fingermark commentedon Oct 12, 2015
Weird. Running into this too when output publicPath isn't set to the full URL.
sokra commentedon Oct 15, 2015
Setting
output.publicPathto an absolute URL should fix the issue, see style-loader README.mrbinky3000 commentedon Mar 28, 2016
This still seems to be an issue. Using webpack v1.12.14, css-loader v0.23.1. When sourcemaps are on, background-images will not work. Setting
output.publicPathto a full url does nothing to resolve the problem.evenfrost commentedon Jun 8, 2016
I can confirm that setting
output.publicPathto a full url fixed the problem for me. My webpack server is hosted on port 5000, my related chunk of config looks as follows:I write Stylus as follows:
It produces following output in generated css:
which is proprely seen and parsed by the browser.
This is the only workflow that works for me. Hope this helps someone.
fingermark commentedon Aug 16, 2016
Has this been fixed in another ticket? I can't seem to find anything.
liu-dongyu commentedon Sep 8, 2016
Still facing this problem. I dont want to set an absolute URL like
http://... So only thing i can do is to remove thesourceMapciasej commentedon Sep 11, 2016
I am having issues with this as well, hoping for a solution that doesn't involve setting an absolute url on publicPath. Webpack is pretty much useless as build tool in your development workflow if you cannot use source maps to understand what styles are needing to be adjusted when viewing an elements styling.
henrikra commentedon Oct 26, 2016
Only solution that worked for me was to use sourceMaps with extract-text-webpack-plugin to extract css to own file + change devtool from "eval-source-map" to "source-map".
Only problem now is that hot reload is veery slow because of high quality source maps. So this is viable only for staging or production environment :)
riccardolardi commentedon Dec 3, 2016
Has this been resolved in the meantime?
kuon commentedon Dec 15, 2016
I faced this issue as well, I disabled source map as absolute URL in public path does not fix the problem.
mhfowler commentedon Feb 4, 2017
Hi I'm still having this issue. I was not able to resolve it by setting output.publicPath to an absolute URL either :(
here is a repository I made demonstrating the problem: https://github.com/mhfowler/Webpack-Example/
When I remove sourceMap from the css-loader there is no issue.
But with sourceMap, images set for background-image via url() are unable to load.
Any help is appreciated, or if you can identify in my webpack config that would be great.
Here is a link to my webpack config: https://github.com/mhfowler/Webpack-Example/blob/master/webpack.config.babel.js
kisnows commentedon Feb 5, 2017
@mhfowler The same.
mrdulin commentedon Feb 21, 2017
@mhfowler Same issue. enable
css module, background-image via url() are unable to load withurl-loader, butDataUrlcan work.