I have created a library for handling my tokens during local development. It contains a CLI tool which dynamically fills a JSON file with the current tokens, and a JavaScript function to load the tokens from the JSON file into my Angular application. With the Webpack-based builder it worked perfectly.
But after I switched to the application builder, I started to have issues with the cache. Initially it works fine, but as soon as my tokens expire and I run the CLI tool to update the tokens, the JSON file is updated, but still the old tokens are used in my app. After some investigation I found out that the tokens are stored in the .angular
folder (cache).
For now I have disabled the cache via ng cache disable
which works fine. However I now see the following warning when running ng serve
:
Prebundling has been configured but will not be used because caching has been disabled.
Also, I would like to use the cache to optimize the dev server, and just exclude this library from the caching. How can I achieve this?
The caching of the project's dependencies is also referred to as prebundling. You can exclude dependencies from prebundling in your angular.json
via the prebundle
configuration in the serve
target:
{
"projects": {
"your-project": {
// ...
"architect": {
// ...
"serve": {
// ...
"configurations": {
// ...
"development": {
"buildTarget": "your-project:build:development",
// Add the following line:
"prebundle": { "exclude": ["my-lib" ] }
}
}
}
}
}
}
}