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

Error with using background-image: url('some.jpg'); #33

Open
teikirizi opened this issue Aug 13, 2019 · 2 comments
Open

Error with using background-image: url('some.jpg'); #33

teikirizi opened this issue Aug 13, 2019 · 2 comments

Comments

@teikirizi
Copy link

I got an error after adding a css rule with backgroung-image: url(some.jpg). After searching a bit I fix it by adding file-loader (yarn add file-loader --dev) and adding this to webpack.config.js rules:
{
test: /.(png|jpe?g|gif)$/i,
use: [
{
loader: 'file-loader',
},
],
},

It's working but I don't know if it's a good solution.

@Alina-chan
Copy link

It's a right approach. The options you have are either using the file-loader package or excluding the images folder entirely from the build.

@onetdev
Copy link

onetdev commented Jun 2, 2020

Thanks for the lead, this will end up with a dysfunctional successful build containing url([object Module]). Just turn off the esModule flag. Now you can use your src as your root path.

{
  test: /.(png|jpe?g|gif)$/i,
  use: [
    {
      loader: 'file-loader',
      options: { esModule: false },
    },
  ],
},

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

3 participants