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

How to import image files from scss file #20

Closed
eguneys opened this issue Jul 28, 2015 · 4 comments
Closed

How to import image files from scss file #20

eguneys opened this issue Jul 28, 2015 · 4 comments

Comments

@eguneys
Copy link

eguneys commented Jul 28, 2015

If I import a png file from a js file like this:

import 'public/image.png' it works.

but I can't import within scss file like this:

.logo {
  background: url('public/image.png')
}

this gives me module not found error.

@badsyntax
Copy link
Owner

Please paste the full error.

@eguneys
Copy link
Author

eguneys commented Jul 29, 2015

ERROR in ./~/css-loader?sourceMap!./~/postcss-loader!./~/sass-loader?outputStyle=expanded&includePaths[]=/home/ubuntu/webdev/learn/react-facebook-pt/app/scss&includePaths[]=/home/ubuntu/webdev/learn/react-facebook-pt/node_modules&sourceMap&sourceMapContents=true!./app/components/PokerLobby/_PokerLobby.scss
Module not found: Error: Cannot resolve 'file' or 'directory' ./public/poker/main_screen/logo.png in /home/ubuntu/webdev/learn/react-facebook-pt/app/components/PokerLobby
 @ ./~/css-loader?sourceMap!./~/postcss-loader!./~/sass-loader?outputStyle=expanded&includePaths[]=/home/ubuntu/webdev/learn/react-facebook-pt/app/scss&includePaths[]=/home/ubuntu/webdev/learn/react-facebook-pt/node_modules&sourceMap&sourceMapContents=true!./app/components/PokerLobby/_PokerLobby.scss 6:106-152

I am not using local styles, this commit 7404883.

@eguneys
Copy link
Author

eguneys commented Jul 29, 2015

Also this works: webpack-contrib/style-loader#55

@badsyntax
Copy link
Owner

It shouldn't matter if you're using local styles or not, the resulting css should be processed by the style-loader regardless of how you generate the css.
What is the publicPath you set? Based on my own experience, and based on the comments in that issue, it has to be absolute. When I had this issue in the past, I could not figure out if webpack supports "relative" publicPate, I don't think it does.

@eguneys eguneys closed this as completed Jul 29, 2015
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

2 participants