webpack-contrib / cache-loader

[DEPRECATED] Caches the result of following loaders on disk
MIT License
637 stars 51 forks source link

using with file-loader, files are not builded if in cache, even if dist folder is empty #82

Open ValeryVS opened 5 years ago

ValeryVS commented 5 years ago

Expected Behavior

file-loader outputs all to assets folder. cache-loader used with file-loader. While using with file-loader, if output directory does not content assets folder — get those files from cache and put in assets folder.

Actual Behavior

Webpack doesn't output assets folder, that shoul be generated by file-loader.

Code

        {
          test: /.(jpg|jpeg|png|svg|gif|ttf|otf|eot|woff|woff2)$/,
          use: [
            {
              loader: 'cache-loader'
            },
            {
              loader: 'file-loader',
              options: {
                outputPath: 'assets',
                name: isDevelopment ? '[path][name].[ext]' : '[hash].[ext]'
              }
            }
          ]
        }

How Do We Reproduce?

Add cache-loader before file-loader.

alexander-akait commented 5 years ago

You don't need cache-loader on file-loader, why you do this? Anyway it should works, please create minimum reproducible test repo, thanks

EECOLOR commented 4 years ago

I encountered the same problem with this config:

        {
          test: /\.(jpe?g|png|gif)$/,
          loaders: [
            'cache-loader',
            urlLoader,
            isProduction && imageLoader,
            imageSizeLoader
          ].filter(Boolean)
        },

The comment from @evilebottnawi helped me to realize it should be this:

        {
          test: /\.(jpe?g|png|gif)$/,
          loaders: [
            urlLoader,
            'cache-loader',
            isProduction && imageLoader,
            imageSizeLoader
          ].filter(Boolean)
        },

@evilebottnawi It might a good idea to mention in the readme that it should not be placed before any loader that has side effects like emitFile.

Rush commented 4 years ago

You don't need cache-loader on file-loader, why you do this? Anyway it should works, please create minimum reproducible test repo, thanks

It's needed if you have expensive plugins for optimizing images or other assets.

Akiq2016 commented 3 years ago

You don't need cache-loader on file-loader, why you do this? Anyway it should works, please create minimum reproducible test repo, thanks

https://github.com/Akiq2016/test-cache-loader here is my minimum reproducible test repo

alexander-akait commented 3 years ago

Please migrate on https://webpack.js.org/configuration/other-options/#cache