39

According to the docs, there's nothing called .angular being regarded. Yet, in my project, I get that directory, immediately in the root of the project (on the same level as e.g. package.json).

It wasn't there before because my .gitignore would've barked at it. Currently, I'm trying out the latest Angular version, 13.0 and I conclude that it's a new addition to the tooling. Probably, it's some temporary stuff, since its contents are the following.

  • .angular/cache/angular-webpack
  • .angular/cache/babel-webpack

It was pointless to google .angular directory dot what is and the only (semi-)relevant hit I got was the docs linked above.

What's up with .angular directory and do I need to care (and/or version control it)?

Konrad Viltersten
  • 36,151
  • 76
  • 250
  • 438
  • 2
    https://angular.io/guide/workspace-config#cache-options. If you used the Angular CLI, the `.gitignore` will tell you whether or not that should be included (it shouldn't). – jonrsharpe Nov 22 '21 at 17:20
  • 1
    @jonrsharpe I used Angular CLI but I got the *.gitignore* from my pre-generated repo not specific to Angular. Thanks! – Konrad Viltersten Nov 22 '21 at 17:23
  • 2
    > Angular now supports the use of persistent build cache by default for new v13 projects -> https://blog.angular.io/angular-v13-is-now-available-cce66f7bc296#05df – skink Nov 22 '21 at 17:27
  • It's not entirely clear why you're not using the `.gitignore` the CLI also generates/updates for you, but OK. – jonrsharpe Nov 22 '21 at 17:28
  • 3
    @jonrsharpe I **do** use *.gitignore*. But I fetched it from the pre-existing repo and there's nothing Angular-specific so that particular directory wasn't mentioned in the file. I didn't use the version created when I started the new project because I never do and it's the first time it surprised me. I'll know better for the next time. Or I simply will add `/.angular/cache` (copied form a new project) to the existing one. What do you think about that? Am I missing something additional? – Konrad Viltersten Nov 22 '21 at 18:21

2 Answers2

31

".angular/cache" folder should be ignored by your version control system (git, svn etc...)

Example for git, add this line to .gitignore file

.angular/cache

(source : ng new command with @angular/cli v13)

bmtheo
  • 974
  • 1
  • 7
  • 16
13

If you generated your project by using Angular CLI, those will be already included in your .gitignore file as below.

# Miscellaneous
/.angular/cache 

Caching is enabled by default in angular for the development environment. That's why you can see the .angular folder in the project root and of course it does not need to add in repo.

Enabling and disabling the cache

Caching is enabled by default. To disable caching run the following command:

ng config cli.cache.enabled false

To re-enable caching, set cli.cache.enabled to true.

Cache environments

By default, disk cache is only enabled for local environments.

To enable caching for all environments, run the following command:

ng config cli.cache.environment all

rohithpoya
  • 865
  • 7
  • 20