分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

angular default project (angular.json的解读)

发布时间:2023-09-06 02:36责任编辑:白小东关键词:jsjson

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.


This article is part of a collection of tips for managing Angular workspaces.

angular default project (angular.json的解读)

原文地址:https://www.cnblogs.com/oxspirt/p/10613554.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved