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

Loading images in css #93

sergeysova opened this issue Nov 18, 2015 · 3 comments

Loading images in css #93

sergeysova opened this issue Nov 18, 2015 · 3 comments


Copy link

@sergeysova sergeysova commented Nov 18, 2015

I try:

# ./style.css
.searchBg {
  background-image: url(sprite/searchBg.jpg)
# ./component.js
import css from './style.css';

// begin component
  <div className={css.searchBg} />
// end component

What i see in chrome:

But image not loading to background.
When i click on "Open Link in new tab", link opens as:


Copy link

@Strate Strate commented Dec 3, 2015


Note about source maps support and assets referenced with url: when style loader is used with ?sourceMap option, the CSS modules will be generated as Blobs, so relative paths don't work (they would be relative to chrome:blob or chrome:devtools). In order for assets to maintain correct paths setting output.publicPath property of webpack configuration must be set, so that absolute paths are generated.

Btw, why style-loader can not replace relative urls to absolute urls by itself?

Copy link

@tizmagik tizmagik commented Feb 1, 2016

See #55 for some workarounds/solutions to this issue.

d4rkr00t added a commit to d4rkr00t/aik that referenced this issue Jan 4, 2017
According to this issue webpack-contrib/style-loader#93 it's impossible to load

images with relative urls that defined in css with sourceMap flag enabled. Will investigate further.

But as for now it's reasonable to disable sourcemaps for css-loader
Copy link

@michael-ciniawsky michael-ciniawsky commented Mar 6, 2017

Will be fixed by either #96 or #124

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants