Webpack-cli: [Migrate] loaders transform: should options be always grouped with the loader

Created on 23 May 2017  路  8Comments  路  Source: webpack/webpack-cli

Do you want to request a feature or report a bug?
Bug/Question?

What is the current behavior?

This:

     {
        test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
        loader: 'url-loader',
        options: {
          limit: 10000,
          name: 'static/media/[name].[hash:8].[ext]'
        }
      },

will be converted to this:

      {
        test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
        use: [{
          loader: 'url-loader'
        }],
        options: {
          limit: 10000,
          name: 'static/media/[name].[hash:8].[ext]'
        }
      },

Question is: is this correct result or should options be grouped with the loader?

cc @sokra

AST Transform Bug enhancement

Most helpful comment

Thanks @schmuli! I'll need to update code to make this happen.

All 8 comments

Any status update on this?

@okonet - Can options be bound to multiple loaders? Isn't it more clearer to group them with the loaders?

Can options be bound to multiple loaders?

I don't know! That's why I've created this issue.

According to the webpack TypeScript definition files, a UseRule (i.e. a rule with a use property) can not have an options property.

So you either need to continue using a LoaderRule (i.e. loader and options properties, or you need to specify the options in the use property, either as an object or as an array.

Thanks @schmuli! I'll need to update code to make this happen.

@okonet @pksjce any of you guys got time to do this?

I will take a crack at this, the out put should be something like this right ?

{
        test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
        use: [{
          loader: 'url-loader'
        },
        options: {
          limit: 10000,
          name: 'static/media/[name].[hash:8].[ext]'
        }]
      },
Was this page helpful?
0 / 5 - 0 ratings