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?
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With