What's the .angular directory in the project root about?
Asked Answered
K

2

41

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)?

Kerwon answered 22/11, 2021 at 17:17 Comment(5)
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).Obstinacy
@Obstinacy I used Angular CLI but I got the .gitignore from my pre-generated repo not specific to Angular. Thanks!Kerwon
> Angular now supports the use of persistent build cache by default for new v13 projects -> blog.angular.io/angular-v13-is-now-available-cce66f7bc296#05dfStick
It's not entirely clear why you're not using the .gitignore the CLI also generates/updates for you, but OK.Obstinacy
@Obstinacy 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?Kerwon
G
33

".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)

Gladsome answered 30/11, 2021 at 22:25 Comment(0)
G
15

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

Gwendolyngweneth answered 11/4, 2022 at 14:53 Comment(1)
Thanks this is what I want, If someone need to know further, angular.io/cli/cacheMetre

© 2022 - 2024 — McMap. All rights reserved.