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

Comments

Projects
None yet
4 participants
@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:
image

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

image

@Strate

This comment has been minimized.

Show comment
Hide comment
@Strate

Strate 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?

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

This comment has been minimized.

Show comment
Hide comment
@tizmagik

tizmagik Feb 1, 2016

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

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

fix(webpack): Disable sourcemaps for css
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

This comment has been minimized.

Show comment
Hide comment
@michael-ciniawsky

michael-ciniawsky Mar 6, 2017

Member

Will be fixed by either #96 or #124

Member

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