ag-grid is proud to partner with webpack

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
Name
cacheDirectory
Type
{String}
Default
path.resolve('.cache-loader')
Description
Provide a cache directory where cache items should be stored
Name
cacheIdentifier
Type
{String}
Default
cache-loader:{version} {process.env.NODE_ENV}
Description
Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders.

Examples

webpack.config.js

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

##

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