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

Adding background form scss doesn't work #25

Open
Silver360 opened this issue Feb 24, 2019 · 5 comments
Open

Adding background form scss doesn't work #25

Silver360 opened this issue Feb 24, 2019 · 5 comments
Assignees

Comments

@Silver360
Copy link

Silver360 commented Feb 24, 2019

When I try add image as background, picture not showing. My code looks like this.

.bg { background-image: url('../assets/section-packets-bg.png'); }

webpack generate this url url("http://localhost:8080/../../assets/section-packets-bg.png")

@lifenautjoe
Copy link
Owner

Hi @Silver360 , I'll take a look.

Could you meanwhile try to load it from ./assets/section-packets-bg.png ?

Cheers.

@NathanHealea
Copy link

Hi @Silver360 , Give this a try.

npm install --save-dev resolve-url-loader

webpack.dev.js

{
  // translates CSS into CommonJS
  loader: 'css-loader',
  ...
},
{
  loader:'resolve-url-loader',
  option: {
    sourceMap: true
  }
},
{
  // compiles Sass to CSS
  loader: 'sass-loader'
  ..
}
...

In your sass file use a relative path. In the file structure I'm using I have an image directory under styles
styles/index.scss

.bg { background-image: url('img/section-packets-bg.png'); }

@ldraminski
Copy link

Hi thanks for replay. When I try install resolve-url-loader I get this message.
screenshot_1

@NathanHealea
Copy link

@ldraminski,

That message indicated that there are vulnerabilities in the package that you installed.
You can either run npm audit fix or just ignore them.

@annelyse
Copy link

Option with a S , if not it doesn't work !

{
loader:'resolve-url-loader',
options: {
sourceMap: true
}
},
{

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

No branches or pull requests

5 participants