Ionic serve didn't call cordova hooks


#1

I’ve used Ionic to execute commands like build, run, etc. I’m thinking weird why when I execute command “cordova serve”,
the hooks (before_serve) works, but whether I execute command “ionic serve” didn’t work, does somebody know like I solve this to execute with “ionic serve” ?


#2

Hi @carlossj.
I am having the same issue. Did you find a workaround ?
Regards.


#3

Same here. I’m working around it by using gulp to run the hooks, but… ugly

Issue raised in ionic_cli project


#4

how did you do this with gulp exactly?


#5

I’m using gulp serve instead of ionic serve.
Gulp serve runs all the hooks in the .hooks/before_serve and .hooks.before_prepare folders use shelljs then runs ionic serve. as normal. I also played with using ionic.project to kick off a gulp task in the gulpDependantTasks and gulpStartupTasks array, but settled on gulp serve.

Alternatively, I could have run ‘cordova serve’ and all would be good i’m sure, but argh!! Why!

I’m moving on to ionic 2 now, so I expect its all different again.


#6

Nice!! Could you please share your gulp serve task code? :slight_smile:
Btw I did try just now the cordova serve but it doesnt work really well (came up with a page without any styles)

Edit: I just created a gulp task “serve” and added it to the gulpStartupTasks in ionic.project with the following:

gulp.task('serve', function () { exec('node hooks/before_serve/before_serve_custom.js'); });

Looks like it is working fine