# Gulp tasks run on build

**URL:** <https://forum.ionicframework.com/t/gulp-tasks-run-on-build/21417>\
**Category:** uncategorized\
**Created:** [April 21, 2015, 5:58pm UTC](https://forum.ionicframework.com/t/gulp-tasks-run-on-build/21417 "2015-04-21T17:58:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinob11](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kevinob11/32/85555_2.png) [@kevinob11](https://forum.ionicframework.com/u/kevinob11)\
**Post date:** [April 21, 2015, 5:58pm UTC](https://forum.ionicframework.com/t/gulp-tasks-run-on-build/21417/1 "2015-04-21T17:58:57Z")

</div>

Right now when I use `ionic serve` it runs the gulp startup tasks in my ionic.project. Are there gulp tasks run on ionic build? I’d love to run a task to replace base urls for my api calls when I build but I don’t see a way to do that. I know I can just call `gulp [whatever]` then call `ionic build` but I’d prefer it would be automated.

---

<div class="post-metadata">

**Author:** ![bobrov1989](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/bobrov1989/32/98131_2.png) [@bobrov1989](https://forum.ionicframework.com/u/bobrov1989)\
**Post date:** [April 22, 2015, 1:35pm UTC](https://forum.ionicframework.com/t/gulp-tasks-run-on-build/21417/2 "2015-04-22T13:35:18Z")

</div>

you have to use cordova hooks to run some code on build

---

<div class="post-metadata">

**Author:** ![gioy](https://avatars.discourse-cdn.com/v4/letter/g/6bbea6/32.png) [@gioy](https://forum.ionicframework.com/u/gioy)\
**Post date:** [September 17, 2015, 10:43am UTC](https://forum.ionicframework.com/t/gulp-tasks-run-on-build/21417/3 "2015-09-17T10:43:40Z")

</div>

Hi,  
I had to do exactly what you’re asking for, and after a little research, I came out with something that works:

1. create a hook file inside _/hooks/appropriate\_phase/xy\_hook\_name.js_

where:

- _appropriate\_phase_ must be one taken from the following list: [https://cordova.apache.org/docs/en/edge/guide\_appdev\_hooks\_index.md.html](https://cordova.apache.org/docs/en/edge/guide_appdev_hooks_index.md.html)
- _xy\_hook\_name.js_ is the hook file name. xy should be numbers. This is just a convention for executing hooks in a specific order. However, since node.js code is asynchronous, you’ll have to handle it if you need sequential/synchronous code execution.

1. use the following code inside the hook file you did create in step 1:

source: [https://stackoverflow.com/questions/28308360/gulp-hook-before-cordova-build-xxx/28461521#28461521](https://stackoverflow.com/questions/28308360/gulp-hook-before-cordova-build-xxx/28461521#28461521)

Be Aware that the `gulp.start('gulp-task-name')` method appears to be doomed to deprecation/removal. This is not a stable/long term solution. But it does work as today (17th of September 2015) with the following system information:

```
Cordova CLI: 5.2.0
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic CLI Version: 1.6.4
Ionic App Lib Version: 0.3.8

```

Hope that helps! Good Luck!
