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

wrong URLs [object Object] with file-loader@1 #140

Closed
andrenarchy opened this issue Aug 6, 2017 · 2 comments
Closed

wrong URLs [object Object] with file-loader@1 #140

andrenarchy opened this issue Aug 6, 2017 · 2 comments
Projects
Milestone

Comments

@andrenarchy
Copy link

I'm submitting a bug report

Webpack version:
3.4.1

HTML-Loader version:
0.5.0

Please tell us about your environment:
Linux

Current behavior:
When used with file-loader@1 it creates HTML like <img src="[object Object]"> from <img src="img/logo.png">.

Expected/desired behavior:
It should insert the path of the file that file-loader created, e.g., <img src="img/logo.a1f96acab.png">.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.

This is the relevant part of the webpack config:

{
  // ...
  module: {
    rules: [
      {
        test: /\.html$/,
        use: [{
          loader: 'html-loader',
          options: {interpolate: 'require'}, // allow ${require(...)} in html
        }],
      },
      {
        test: /\.(jpg|png|svg)$/,
        use: [
          {
            loader: 'file-loader',
            options: {name: '[path][name].[md5:hash:hex:8].[ext]'},
          },
          {
            loader: 'image-webpack-loader',
            options: {},
          },
        ],
      },
      // ...
    ]
  }
}

The returned object from file-loader looks like {default: 'img/logo.a1f96acab.png'} and file-loader@1 switched to es6 default imports so it looks like this issue is similar to the css-loader problem reported in webpack-contrib/file-loader#181.

@michael-ciniawsky
Copy link
Member

The best solution for now is to pin file-loader at v0.11.2. We oversaw that exporting an ES2015 Module in v1.0.0 causes problems with html-loader, css-loader's asset resolving which uses require('path/to/asset') and doesn't work with an ES2015 export yet => require('path/to/asset').default.

@cyberhck
Copy link

cyberhck commented Feb 18, 2018

how's this closed? in which commit? what's the solution for now?
edit: never mind, I just updated to latest version, and it works, but maybe a good idea to include the commit which closed this one, or something 🙂

jerivas added a commit to unplugstudio/mezzanine-boilerplate that referenced this issue Aug 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Dashboard
Awaiting triage
Development

No branches or pull requests

3 participants