Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

[Feature Request] Allow cacheKey customization #303

Closed
Rohit-L opened this issue May 27, 2018 · 2 comments
Closed

[Feature Request] Allow cacheKey customization #303

Rohit-L opened this issue May 27, 2018 · 2 comments

Comments

@Rohit-L
Copy link

Rohit-L commented May 27, 2018

Hello all,

Would it be possible to add an option to allow us to customize the cacheKey when caching?

Currently, this is the predefined cacheKey that is used.

            if (this.options.cache) {
              task.cacheKey = serialize({
                'uglify-es': versions.uglify,
                'uglifyjs-webpack-plugin': versions.plugin,
                'uglifyjs-webpack-plugin-options': this.options,
                path: compiler.outputPath ? `${compiler.outputPath}/${file}` : file,
                hash: crypto.createHash('md4').update(input).digest('hex'),
              });
            }

My use case is that on my production build machine, I will clone my repo into a temporary folder. The name of the temp folder is the git hash. My goal is to have the uglify cache reside outside this temp folder (which is doable as the cache option takes a string which is the cache directory).

My issue is that the cache doesn't help in this case as the cacheKey takes compiler.outputPath into consideration (the output path contains my temp folder name). Therefore, nothing will hit in the cache.

An option to allow me to customize the cacheKey that is used would let me define it so that compiler.outputPath is not used in the cacheKey.

@alexander-akait
Copy link
Member

@Rohit-L

  1. Very very very weird use case. Looks you are trying to do something here, what should be do in another way. You should review you workflow with caches. It is just recommendation.
  2. additionalCacheKeys - options, also please update docs and write tests on this (PR welcome).

For other developers: in near future we allow using uglif-js and other forks based on uglify have same api. For invalidate cache we should add option.

@alexander-akait
Copy link
Member

Done in #320

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants