How to run PostBuild Script in Package.json in Angular Project

In this tutorial, you will learn how to execute scripts after the angular application build is complete. There may be some scripts that need to be run after the build is complete and we have the dist folder created.

This Angular post is compatible with Angular 4 upto latest versions, Angular 7, Angular 8, Angular 9, Angular 10, Angular 11, Angular 12 and Angular 13

In situations where we want to execute operations after the Angular project build is complete, we can run the post-build script.

For example, in our case, we want to copy the dist folder after the project build is completed.

This is how you can execute the post build script in package.json

Add the “postbuild” script as shown below and append it after the ng build command.

"scripts": {
    "postbuild":"cp -TR ./dist/my-app ../built-apps/my-new-app/dist-apps",
    "build": "ng build && npm run postbuild",

Leave a Reply

Your email address will not be published. Required fields are marked *