ionic-cli icon indicating copy to clipboard operation
ionic-cli copied to clipboard

Trigger Gulp when building

Open w3apps opened this issue 11 years ago • 5 comments

It would be nice to trigger a Gulp task when you run "ionic build ios/android". I think it would be a cool feature to be able to do some work on the deployed files before it builds for a specific platform.

w3apps avatar Apr 01 '15 14:04 w3apps

My problem with this: If we add a pre-build-gulp hook, why don't we add a pre-build hook for shell scripts too? And everything else.

The CLI already has tons of features. Can't you just make a shell script?

# build.sh
gulp pre-build
ionic build ios

Boom!

ajoslin avatar Apr 01 '15 23:04 ajoslin

@ajoslin I think your suggestion is a good workaround. Although, Since gulp is a part of ionic and performs steps related to the build such as SASS processing I agree with the author. I think it should be supported in the build command.

adamduren avatar Apr 16 '15 15:04 adamduren

I agree with @adamduren, if we're going to have 'gulpStartupTasks' be an option then we should have options for all well-known steps (https://docs.npmjs.com/misc/scripts).

@ajoslin's solution, while fine for a 'pre-build' script, is insufficient for complex tasks when using 'watch', and can result in race conditions and non-deterministic build scenarios depending on the length of tasks being performed. I use browserify with watch and live-reload when I develop, and there's no clean way to integrate it with the current setup, from what I can see.

My opinion is that the 'serve' command should use the generated gulp file for dev tasks, so that the user can customize it as needed.

TJKoury avatar May 17 '15 12:05 TJKoury

It's a bit convoluted, but here's my approach:

  • ionic.project: gulpStartupTasks: ["watch"]
  • gulpfile.js: watch: set pattern to include source files and exclude dist/build files (and exclude vendor files)
  • ionic.project: watchPatterns: set pattern to only include dist/build files

So live-reload still works, etc.

jokeyrhyme avatar Dec 22 '15 21:12 jokeyrhyme

Thanks for opening the issue. It seems that issue has been resolved. I am going to close this issue but please feel free to reopen another issue if this occurs again.

jthoms1 avatar Sep 30 '16 18:09 jthoms1