1.0.2 • Published 4 years ago

@mokahr/cache-manage-plugin v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

cache-manage-plugin

A Webpack plugin used to manage multiply cache Directory.

Manage different code caches based on the hash.

Usage

  1. Install dependency.

npm install --save-dev @mokahr/cache-manage-plugin

  1. Update webpack config file.
const CacheManage = require('@mokahr/cache-manage-plugin');

const someHash = createHash();
// your webpack config
module.exports = {
  module: {
    rules: [
      {
        loader: 'babel-loader',
        options: {
          cacheDirectory: `node_modules/.cache/babel-loader/${someHash}`,
        },
      },
    ]
  }
  ...
  plugins: [
    ...
    new CacheManage({    // use
      cacheHash: someHash, 
      dependencyCachePaths: [`node_modules/.cache/babel-loader/${someHash}`],
    }), 
  ]
}

Configuration

new CacheManage(options)

optional options.cacheRecordPath: string

cache directory, default value is node_modules/.cache

required options.cacheHash: string

cacheHash mast provide;

optional options.maxAge: number

cache max age, default value is 1 * 24 * 60 * 60 * 1000 one day

optional options.dependencyCachePaths:

need to manage cache's cacheDirectory list, default value is []