angular-cli run command after ng build

Issue

I am wondering how to extend ng build to run tasks after it has finished.

At the moment, my end goal is to copy my ‘package.json’ to the dist folder.

Something like this if I was using plain npm:

"postbuild": "cpx ./package.json ./dist/",

I know in the angular-cli.json I can use "assets" to copy static files, but it does not work for files outside of src. So, I’m wondering if I can do the copy task after ng build completes.

Solution

Define an npm script

"build":" "ng build"

and add the postbuild script, too.

"postbuild": "cpx ./package.json ./dist/",

This way the copy script gets called after you run npm run build.

Answered By – Alexander Ciesielski

Answer Checked By – Candace Johnson (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.