Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 6 CLI -> how to make ng build build project + libraries

Tags:

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

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.

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

like image 974
dendimiiii Avatar asked May 04 '18 18:05

dendimiiii


People also ask

What Angular CLI command can be used to create a library?

Use the Angular CLI and the npm package manager to build and publish your library as an npm package. Angular CLI uses a tool called ng-packagr to create packages from your compiled code that can be published to npm.


1 Answers

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"   }, 

and then

yarn run build-all 
like image 163
oklymenk Avatar answered Nov 13 '22 03:11

oklymenk