好好爱自己!

angular default project (angular.json的解读)

Change the default Angular project

Understanding it's purpose and limits

Angular's default project is nothing more than a string, set in angular.json, to say which project should run with ng commands without a defined project.

Note: The defaultProject key was set to be deprecated in 7.0.0 , but it was blocked because there should be a large discussion about project layout for 8.x.x.

Let's create a new project called my-app:

$ ng new my-app

It will create an angular.json with the following structure:

{
...,
"projects": {
"my-app": { ... },
"my-app-e2e": { ... },
},
"defaultProject": "my-app",
}

So, when you run ng serve , it would serve my-app. It would be the same as running ng serve my-app.

Setting a new default project

To understand what values are valid, let's create a library and an application.

$ ng create application my-application
$ ng create library my-library

Now, we have the following structure:

{
...,
"projects": {
"my-app": { ... },
"my-app-e2e": { ... },
"my-application": { ... },
"my-application-e2e": { ... },
"my-library": { ... }
},
"defaultProject": "my-app",
}

The highlighted values ( my-appmy-application and my-library) are the valid ones to use as the defaultProject. E2E projects are not valid ones, even if they are listed as projects, because they are used on ng e2e.

If you created a blank workspace or just deleted the default project string, the first project you create (in this case my-application) will automatically be set as the default project.

Commands

Each project type has their own commands to use, for example:
Applications: servebuildteste2e and xi18n.
Libraries: build and test.


posted @   立志做一个好的程序员  阅读(774)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
历史上的今天:
2018-03-28 什么是分布式系统(通俗易懂的说法)
2018-03-28 什么是分布式系统,分布式系统例子?
2018-03-28 【转】Linux cp -a用法
2017-03-28 influxDB系列(二)
2017-03-28 influxDB系列(一)

不断学习创作,与自己快乐相处

点击右上角即可分享
微信分享提示