Skip to content

Allow disabling CLI cache in ng serve via command-line flag #30308

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bartadaniel opened this issue May 14, 2025 · 5 comments
Closed

Allow disabling CLI cache in ng serve via command-line flag #30308

bartadaniel opened this issue May 14, 2025 · 5 comments
Labels
angular/build:dev-server area: @angular/build feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature

Comments

@bartadaniel
Copy link

Command

serve

Description

Currently, the recommended way to disable the Angular CLI cache is via ng cache enable and ng cache disable, which modifies the cli.cache.enabled setting in angular.json.

In some situations, I need to disable the cache while serving the app. However, I’d prefer not to change the project configuration every time, especially since doing so slows down the build process and requires cleanup before committing. Each time I need the cache disabled, I have to manually edit angular.json and later revert the change. It'd be great if I could avoid these steps.

Describe the solution you'd like

Having a --no-cache option for ng serve would make this workflow much smoother. It would disable caching only for that specific run, leaving the global configuration untouched.

Describe alternatives you've considered

I can automate this process using the trap command in a shell script, but since trap doesn’t work on Windows, I’d need to maintain a custom script, which complicates things unnecessarily for this simple problem.

@alan-agius4
Copy link
Collaborator

Out of curiosity why sometimes do you need to disable the cache during ng serve?

@alan-agius4 alan-agius4 added area: @angular/build feature Issue that requests a new feature labels May 14, 2025
@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label May 15, 2025
Copy link
Contributor

angular-robot bot commented May 15, 2025

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

@bartadaniel
Copy link
Author

I work on a JS/WASM npm package. When I need to debug the integration into my Angular application, I use npm link so the package resides in my node_modules.
If I don’t disable the Angular CLI cache, changes to the WASM file are not picked up as the older version remains cached, and I can’t test my updates.

On the other hand, when I’m working on "regular" Angular development tasks, I prefer to keep caching enabled for performance reasons.

So I frequently need to toggle caching, but I’d rather not modify angular.json each time. Having something similar to a --no-cache flag for ng serve would solve this nicely.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented May 16, 2025

In that case you can use configure the dev-server not to prebundle and cache that particular library.

Example:

"serve": {
    "builder": "@angular-devkit/build-angular:dev-server",
    "options": {
        "prebundle": {
            "exclude": ["lib"]
        }
    }
}

Alternatively you can use ng serve --no-prebundle

@alan-agius4 alan-agius4 closed this as not planned Won't fix, can't repro, duplicate, stale May 16, 2025
@bartadaniel
Copy link
Author

Indeed, thanks for pointing that out. One more reason to migrate to esbuild.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
angular/build:dev-server area: @angular/build feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

3 participants