angular-cli run command after ng build

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.


You can execute any custom script before or after any npm script. This is called 'hooks' and it is included in npm. In your case you can execute a 'post' hook but keep in mind that it is also possible to execute 'pre' hook.

define these 3 scripts in your package.json:

"hello": "echo execute hello",
"prehello": "echo execute prehello",
"posthello": "echo execute posthello"

You can find many more useful information about that here: https://www.marcusoft.net/2015/08/pre-and-post-hooks-for-npm-scripting.html