webpack-contrib / cache-loader

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

No files emitted with responsive-loader #99

Open strarsis opened 4 years ago

strarsis commented 4 years ago

Expected Behavior

Image files emitted by the responsive-loader should correctly cached or at least be written to disk.

Actual Behavior

All image files emitted by the responsive-loader are missing, they are not written as files to disk.

Code

// webpack.config.js
let webpackConfig = {
  module: {
    rules: [
      {
        test: /\.(jpe?g|png)$/i,
        use: [{
          loader: 'cache-loader',
        }, {
          loader: 'responsive-loader',
          options: {
            adapter: require('responsive-loader/sharp'),
            quality: 100, // (default)
            name: '[path][name]-[width].[ext]',
          },
        }],
      },
  [...]
}

How Do We Reproduce?

webpack setup with responsive-loader and cache-loader. First leave the cache-loader disabled and let the responsive-loader resize some images (e.g. during CSS build). Notice that the resized images are correctly written to disk as files. Now enable the cache-loader, run the build again. Notice that these files are not written to disk anymore, they are completely missing. Also inspect the cache folder and notice there are cache files for these resized images, but too small for an image file and they contain similar base64 encoded payload as above.

Additional notes

The cache files are very small for image files, the base64-decoded payload looks like this:

module.exports = {srcSet:__webpack_public_path__ + "images/layout/header-1557.jpg"+" 1557w",images:[{path:__webpack_public_path__ + "images/layout/header-1557.jpg",width:1557,height:743}],src:__webpack_public_path__ + "images/layout/header-1557.jpg",toString:function(){return __webpack_public_path__ + "images/layout/header-1557.jpg"},placeholder: undefined,width:1557,height:743};

No binary data of the actual image files can be found.

alexander-akait commented 4 years ago

Problem still exists? Can you create reproducible test repo?

strarsis commented 4 years ago

@evilebottnawi: Issue still exists, I can try to create a simplified, reproducible test case for this.

alexander-akait commented 4 years ago

@strarsis will be great :+1: