webpack-contrib/cache-loader

No files emitted with responsive-loader

Opened this issue · 3 comments

  • Operating System: WSL 1 (Bash on Windows)
  • Node Version: v8.14.0
  • NPM Version: 6.14.1
  • webpack Version: 3.10.0
  • cache-loader Version: 4.1.0

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.

Problem still exists? Can you create reproducible test repo?

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

@strarsis will be great 👍