G
G
GunAlv2020-12-29 12:36:12
JavaScript
GunAlv, 2020-12-29 12:36:12

How to use file-loader for pictures?

All sources are in src/app. I have a basic configuration for pictures:

{
        test: /\.(webp|png|jpg|jpeg|gif)$/,
        exclude: excludeImages(FAVICON_FILENAMES),
        use: [
          {
            loader: 'file-loader',
            options: {
              name: `${staticDir}/images/[hash].[ext]`,
            },
          },
        ],
      },


In src/app, I create a conditional /special-images directory, the images from which need to be added to `${staticDir}/special-images/images/[hash].[ext]`:

{
        test: /\.(webp|png|jpg|jpeg|gif)$/,
        exclude: excludeImages(FAVICON_FILENAMES),
        include: [
            path.resolve(__dirname, 'src/app/special-images'),
         ],
        use: [
          {
            loader: 'file-loader',
            options: {
              name: `${staticDir}/special-images/images/[hash].[ext]`,
            },
          },
        ],
      },


However, in this case, the configuration is not picked up and the images are still added to static/ (not static/special-images). Tell me, what's the problem?

I can't change the basic configuration

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question