Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

v1.1.0 options.name is failure #138

Closed
lincenying opened this issue Aug 15, 2018 · 3 comments · Fixed by #139
Closed

v1.1.0 options.name is failure #138

lincenying opened this issue Aug 15, 2018 · 3 comments · Fixed by #139

Comments

@lincenying
Copy link

This is my configuration file

{
                test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
                use: [
                    {
                        loader: 'url-loader',
                        options: {
                            name: 'img/[name].[hash:7].[ext]',
                            limit: 8192
                        }
                    }
                ]
            },

This is the generated file

image

v1.0.1 is ok

image

@insin
Copy link
Contributor

insin commented Aug 15, 2018

Confirming the same issue, looks like name isn't getting passed along to the fallback.

conemu64_2018-08-15_13-40-59

@insin
Copy link
Contributor

insin commented Aug 15, 2018

I think it's because v1.0.1 used to do this, so file-loader would pick up all the given options:

const fallback = require(options.fallback ? options.fallback : 'file-loader');
return fallback.call(this, src);

Here's a failing test for fallback.test.js showing failure to pass on the name option to file-loader by default:

    test('{undefined}', async () => {
      const config = {
        loader: {
          test: /\.png$/,
          options: {
            limit: 100,
            name: 'name-for-url-loader.[ext]',
          },
        },
      };

      const stats = await webpack('fixture.js', config);
      const { source } = stats.toJson().modules[0];

      expect(source).toMatchSnapshot();
    });

For this not to be a breaking release, would it need to support passing along all the options file-loader can take, or do what it used to do if a fallback + options aren't explicitly configured?

@hxlniada
Copy link

this is a big bug

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

Successfully merging a pull request may close this issue.

5 participants