angular default project (angular.json的解读)

Change the default Angular project

Understanding it‘s purpose and limits

Klaus KazlauskasFollow

Nov 6, 2018

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.

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

时间: 2024-08-30 00:06:53

angular default project (angular.json的解读)的相关文章

Angular - - angular.uppercase、angular.lowercase、angular.fromJson、angular.toJson

angular.uppercase 将指定的字符串转换成大写 格式:angular.uppercase(string); string:被转换成大写的字符串. 使用代码: var str = "ABCabc"; var upperCase = angular.uppercase(str);//ABCABC angular.lowercase 将指定的字符串转换成小写 格式:angular.lowercase(string); string:被转换成小写的字符串. 使用代码: var s

angular.equals()、angular.extend()、angular.foreach()、angular.fromJson()、angular.identity()等

angular.equals(o1, o2) 解释:参数o1和o2的比较(参数可以为变量.数组.对象) demo:angular.equals({name:'xxx'},{name:'yyy'}); //$ false angular.extend(dst, src) dst:被扩展的目标 src:扩展的对象 解释:对象的扩展,存在的类型进行值得覆盖,不存在的增加该类型. demo: var dst = {name: 'xxx', country: 'China'}; var src = {na

嘿!@野兽,你的ng api 掉了 - - angular.uppercase和angular.lowercase

@野兽的 ng api 学习 -- angular.uppercase和angular.lowercase angular.uppercase 将指定的字符串转换成大写 格式:angular.uppercase(string); string:被转换成大写的字符串. 使用代码: var str = "ABCabc"; var upperCase = angular.uppercase(str);//ABCABC angular.lowercase 将指定的字符串转换成小写 格式:ang

嘿!@野兽,你的ng api 掉了 - - angular.identity和angular.noop

@野兽的 ng api 学习 -- angular.identity和angular.noop angular.identity 函数返回本身的第一个参数.这个函数一般用于函数风格. 格式:angular.identity() 使用代码: <script> angular.module("Demo", []) .controller("testCtrl", ["$scope", function ($scope) { var getR

angular.js 的angular.copy 、 angular.extend 、 angular.merge

<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <script src="js/angular.min.js" type="text/javascript" charset="utf-8"></s

Angular - - angular.injector、angular.module

angular.injector 创建一个injector对象, 调用injector对象的方法可用于获取服务以及依赖注入. 格式:angular.injector(modules); modules:  Array 注入的模块(一个或多个). 使用代码: (function () { angular.module("firstModule", []) .service("firstService", function () { this._log = functi

Angular JS - 6 - Angular JS 常用指令

1 <!DOCTYPE html> 2 <html> 3 <head lang="en"> 4 <meta charset="UTF-8"> 5 <title></title> 6 </head> 7 <!-- 8 1. Angular指令 9 * Angular为HTML页面扩展的: 自定义标签属性或标签 10 * 与Angular的作用域对象(scope)交互,扩展页面的动

微信小游戏 项目配置文件 project.config.json

一.项目配置文件project.config.json 小程序开发者工具在每个项目的根目录都会生成一个 project.config.json,在工具上做的任何配置都会写入到这个文件,当重新安装工具或者换电脑工作时,只要载入同一个项目的代码包,开发者工具就自动会帮你恢复到当时你开发项目时的个性化配置,其中会包括编辑器的颜色.代码上传时自动压缩等等一系列选项. 可以在项目根目录使用 project.config.json 文件对项目进行配置. (1)compileType 有效值: (2)sett

微信小程序 project.config.json 配置

可以在项目根目录使用 project.config.json 文件对项目进行配置. miniprogramRoot Path String 指定小程序源码的目录(需为相对路径) qcloudRoot Path String 指定腾讯云项目的目录(需为相对路径) pluginRoot Path String 指定插件项目的目录(需为相对路径) compileType String 编译类型 setting Object 项目设置 libVersion String 基础库版本 appid Stri