webpack-contrib / file-loader

File Loader
MIT License
1.86k stars 255 forks source link

copying images with picture tag #379

Closed one618 closed 3 years ago

one618 commented 3 years ago

On production file loader is only loading the jpg image, is there is any way to copy both pictures insde picture element ?

<picture>
  <source type="image/webp" srcset="images/hero.webp">
  <source type="image/jpeg" srcset="images/hero.jpg">
  <img src="images/hero.jpg" alt="">
</picture>

so only the jpg will be copied after i build and here is my configuration

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

We don't touch html content, and you ignore the issue template, so I can't help sorry

alexander-akait commented 3 years ago

maybe you need to change test: /\.(gif|png|jpe?g|svg|webp)$/i,