Distributed Cache For Your NX build. Optimize your build time by caching the artifacts across multiple devices.
npm install @magile/nx-distributed-cacheA custom runner for builds in NX to store your build artifacts on a distributed storage.
This custom runner only supports AWS S3 storage for now. Other storages might be added in the future. Feel free to add one and
create a PR.
You may also be able to use Digital Ocean Spaces too, since that is compatible with S3.
nx-distributed-cache is available on npm:
``sh`
npm install @magile/nx-distributed-cache --save-dev
Add or update your taskRunnerOptions in your nx.json to use this custom task runner:
`json`
"tasksRunnerOptions": {
"default": {
"runner": "@magile/nx-distributed-cache/S3",
"options": {
"cacheableOperations": ["build", "lint", "test", "e2e"],
"remoteDirectory": "
"distributedCacheOptions": {
"bucketName": "
"accessKeyId": "
"secretAccessKey": "
}
}
}
},
You can also pass endpoint and region. For e.g. using Digital Ocean Spaces.
Example AWS policy:
`json`
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::
"arn:aws:s3:::
]
}
]
}$3
You can also set all these options as an environment variable in your build-process (e.g. docker ENV, ...):
`js``
process.env.bucketName = 'your-s3-bucket-name';
process.env.accessKeyId = 'your-accessKeyId';
process.env.secretAccessKey = 'your-secretAccessKey';