Short answer: No, you will need to do something else.
Explanation: The Npm postinstall script runs when building Heroku clubs, when you do a git click on the first Heroku application in your pipeline. Subsequently, when you “promote” releases through your Heroku pipeline (for example, from “development” to “production”), the pre-built Heroku plug moves forward “as is” and is not restored.
Therefore, let's say you have a var configuration configured in your development application that will set the argument that you pass "ng build" to "dev". This means that when you git click on your development application, the pool will be created using the "dev" options. This is normal for a "development" application. HOWEVER, when you subsequently promote "production" and "production," you will promote a pre-built slug that was built using the "dev" options, which is NOT what you want.
So, to get the functionality you need, you will need to consider a different approach.
One way to do this is to run the "ng build" script in the "npm prestart" phase. This should work and allow you to use Heroku configuration files to modify your Angular2 application, depending on the phase of the Heroku pipeline on which they are deployed. However, I usually DO NOT recommend this approach. This will cause your "ng build" to run every time "npm start" starts, which quite often happens on Heroku (i.e. at least once every 24 hours or so, plus every time, when your Heroku revolvers restart for any reason). This will cause your application to experience more downtime than necessary. EVERY time your dinosaurs reboot. Not a good idea, usually.
Instead, it is better to use the Angular2 application for your server when it is initialized and return to the server any specific pipeline parameters that your Angular2 application requires based on the regular Heroku configuration configurations.
Yoni rabinovitch
source share