@zaaack/cache-loader
Caches the result of following loaders on disk.
Last updated 3 years ago by zaaack .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @zaaack/cache-loader 
SYNC missed versions from official npm registry.

npm node deps test coverage chat

Cache Loader

Caches the result of following loaders on disk

Install

npm install --save-dev @zaaack/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: [
          '@zaaack/cache-loader',
          ...loaders
        ],
        include: path.resolve('src')
      }
    ]
  }
}

⚠️ Note:

  1. This is a fork version of original cache-loader, by using leveldb & xxhash & level-ttl, we can make cache faster and easier!
  2. 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
cacheIdentifier {String} cache-loader:{version} {process.env.NODE_ENV} Provide an invalidation identifier which is used to generate the hashes. You can use it for extra dependencies of loaders.
ttl {Number} 30 * 24 * 3600 * 1000 (30 days by ms) TTL(time to live) for cache.

Examples

webpack.config.js

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

Options

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [
          {
            loader: '@zaaack/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

Zack Young

Current Tags

  • 1.0.4                                ...           latest (3 years ago)

2 Versions

  • 1.0.4                                ...           3 years ago
  • 1.0.3                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (6)
Dev Dependencies (22)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |