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

Closed
sergeysova opened this issue Nov 18, 2015 · 3 comments
Closed

Loading images in css #93

sergeysova opened this issue Nov 18, 2015 · 3 comments

Comments

@sergeysova
Copy link

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:
image

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

image

@Strate
Copy link

Strate commented Dec 3, 2015

From README:

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?

@tizmagik
Copy link

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
@michael-ciniawsky
Copy link
Member

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants