Skip to content

blade254353074/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

Caches the result of following loaders on disk.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%