Angular 6 CLI->如何使ng build构建项目+库 [英] Angular 6 CLI -> how to make ng build build project + libraries

查看:84
本文介绍了Angular 6 CLI->如何使ng build构建项目+库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以这个问题很基本,但我找不到.

So the question is pretty basic but I can't find it.

我先通过ng new my-project创建了一个新的应用程序,随后又创建了ng g library my-library. 然后,我执行了命令ng build,但是仅在构建我的应用程序,而不是在构建我的库或e2e项目.这是因为在angular.json中,defaultProject设置为my-project.我可以将其更改为我的库,然后ng build会构建lib.

I created a new app through ng new my-project, followed by a ng g library my-library. Then I executed the command ng build, but is is only building my app, and not my library or my e2e projects. This is because in the angular.json defaultProject is set to my-project. I could change it to my-library, and then ng build will build the lib.

有没有一种方法可以让一个ng-build中的所有项目和库都进行角度构建?

Is there a way to let angular build all the project and the libraries in one ng-build?

推荐答案

我刚刚在package.json中添加了一个脚本来做到这一点,找不到更好的方法.

I just added a script to package.json to do that, could not find a better way.

  "scripts": {
    "build-all": "ng build lib1 && ng build lib2 && ng build",
    "build-all-prod": "ng build lib1 --prod && ng build lib2 --prod && ng build --prod"
  },

然后

yarn run build-all

这篇关于Angular 6 CLI->如何使ng build构建项目+库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆