Skip to content
This repository was archived by the owner on Oct 27, 2020. It is now read-only.
This repository was archived by the owner on Oct 27, 2020. It is now read-only.

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

Open

Description

@ValeryVS
  • Operating System: ubuntu 16.04
  • Node Version: 6.14.3
  • NPM Version: 3.10.10
  • webpack Version: 4
  • cache-loader Version: 3.0.1

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.

Activity

  1. alexander-akait commented on Jun 11, 2019

    @alexander-akait
    Member

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

  2. EECOLOR commented on Nov 24, 2019

    @EECOLOR

    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.

  3. Rush commented on Feb 23, 2020

    @Rush

    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.

  4. Akiq2016 commented on Oct 27, 2020

    @Akiq2016

    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

  5. alexander-akait commented on Oct 27, 2020

    @alexander-akait
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions