Adding build scripts using hooks folder

I’m trying to add a simple script to my build process that I’m using to update the build version and date of my app.

I can’t seem to work out where to add this in the hooks.

I would normally add this task into gulp or grunt during the build, but since ionic2 has a scripts file that is in the node_modules, I can’t edit that in order to keep it constant across all the people working on the project.

I’ve tried putting the script in the before_build, after_build, after_prepare and several others, but it doesn’t seem to run.

The script ideally would run before the minify and uglify in the current ionic_app_scripts
or even as part of the copy so it could copy the files then change some variables on the copied rather than on the source.

i recall seeing something about overriding the build scripts using the config.xml but i haven’t been able to find that resource again.

Anyone know a better way of doing this?

https://cordova.apache.org/docs/en/latest/guide/appdev/hooks/

did you find that?

1 Like

@maxx0r yea i’ve seen that, but those cordova hooks dont seem to run at all, I’ve done them with the hooks folders and with the tag in the config.xml and neither run.

You could use ionic hooks. See Configuring ionic cli

Your package.json would look something like this:

"scripts": {
    "ionic:watch:before": "node yourhook.js",
}