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

[DEPRECATED] Caches the result of following loaders on disk

License

Notifications You must be signed in to change notification settings

webpack-contrib/cache-loader

Repository files navigation

npm node deps test coverage chat

Cache Loader

Caches the result of following loaders on disk

Install

npm install --save-dev cache-loader

Usage

Add this loader in front of other (expensive) loaders to cache the result on disk.

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.ext$/,
        use: [
          'cache-loader',
          ...loaders
        ],
        include: path.resolve('src')
      }
    ]
  }
}

⚠️ Note that there is an overhead for saving the reading and saving the cache file, so only use this loader to cache expensive loaders.

Options

Name Type Default Description
cacheDirectory {String} path.resolve('.cache-loader') Provide a cache directory where cache items should be stored

Examples

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
          'cache-loader',
          'babel-loader'
        ],
        include: path.resolve('src')
      }
    ]
  }
}

Options

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
          {
            loader: 'cache-loader',
            options: {
              cacheDirectory: path.resolve('.cache')
            }
          },
          'babel-loader'
        ],
        include: path.resolve('src')
      }
    ]
  }
}

Maintainers


Tobias Koppers

Juho Vepsäläinen

Joshua Wiens

Artem Sapegin

Michael Ciniawsky

Alexander Krasnoyarov

About

[DEPRECATED] Caches the result of following loaders on disk

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published