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. In situations where we want to execute operations after the Angular project build is complete, we…

By.

min read

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.

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 *