Konya
Konya

Reputation: 97

File loader doesn't copy webp images

I'm using file loader with webpack when i build all images are being copied fine except webP format

const images = {
  test: /\.(gif|png|jpe?g|svg|webp)$/i,
  exclude: /fonts/,
  use: [
    'file-loader?name=images/[name].[hash].[ext]',
    config.env === 'production' ? imageLoader : null,
  ].filter(Boolean),
};

all images are copied fine but webP is not copied

Upvotes: 1

Views: 1093

Answers (1)

Anand Gupta
Anand Gupta

Reputation: 366

module: {
  rules: [
    {
      test: /\.(png|jpe?g|gif|webp|svg)$/i,
      loader: 'file-loader',
      options: {
        name: '[name].[ext]',
        outputPath: 'assets/images',
      },
    },
  ],
},

For me this peice of code is working and webp image is getting copied to dist/ folder. I hope you are adding this inside rules array in webpack config file.

Please refer https://github.com/anandgupta193/react-enterprise-starter-kit, Have a look at the webpack configuration (webpack/webpack.common.config.js) done in this repository.

Upvotes: 1

Related Questions