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

查看:32
本文介绍了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.我可以将其更改为 my-library,然后 ng build 将构建该库.

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.

有没有办法让 angular 在一个 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天全站免登陆