zodern:caching-minifier

v0.3.1Published 4 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

zodern:caching-minifier

An easy way to make minifier plugins cache. Extends caching-compiler to add support for minifiers.

The cache key is the file's input hash. Uses both an in-memory and on disk cache.

Example:

1class AwesomeMinifier extends CachingMinifier {
2  constructor() {
3    super({
4      minifierName: 'awesome',
5      defaultCacheSize: 1024*1024*10,
6    });
7  }
8  minifyOneFile(inputFile) {
9    // Should return a { code, sourcemap } object.
10    return Awesomifier.minify(inputFile.getContentsAsString());
11  }
12  processFilesForBundle(files, options) {
13    // normal code for processFilesForBundle
14    // except to minify a file call
15    // this.minifyFile(file);
16  }
17}
18
19Plugin.registerMinifier({
20  extensions: ['js'],
21  archMatching: 'web',
22}, () => new AwesomeCompiler());