We have implemented this solution in our project:
package.json
"scripts": { "nx": "nx", "postnx": "node checkAndClearCache.js", ...
checkAndClearCache.js
const fs = require('fs'); const rimraf = require('rimraf'); const getSize = require('get-folder-size'); const cachePath = 'node_modules/.cache/nx'; const maxCacheMb = 2048; if (fs.existsSync(cachePath)) { getSize(cachePath, (err, size) => { if (err) { throw err; } const MBSize = (size / 1024 / 1024).toFixed(2); console.log(`*** NX cache size is ${MBSize} Megabytes`); if (MBSize > maxCacheMb) { console.log('*** CLEAR NX CACHE ***'); rimraf.sync(cachePath); } }); }
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
We have implemented this solution in our project:
package.json
checkAndClearCache.js