Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic serve ignoring gulpStartupTasks

I have this ionic.project file:

{
  "name": "foobar",
  "app_id": "com.foo.bar",
  "gulpStartupTasks": [
    "styles",
    "source",
    "watch"
  ],
  "watchPatterns": [
    "www/**/*",
    "!www/lib/**/*"
  ],
  "sourceModules": {
    "ionic": "git://github.com/driftyco/ionic.git",
    "ng-cordova": "git://github.com/driftyco/ng-cordova.git"
  }
}

But the gulp tasks are not being executed, I even added some console.logs to debug but nothing happened.

Any ideas?

UPDATE:

I've detected that the gulpStartupTasks are being executed asynchronously with the Ionic initialization, so when Ionic tries to find the www folder and don't find it (because my startup tasks haven't run yet) it fails and kill the process

But if I create an empty www folder to trick Ionic it works but opens a browser with an error saying that the index.html haven't been found

However, some seconds after that I see the startup tasks being executed in my shell

And if I refresh the page it works

How can I make these startup tasks run before ionic tries to find the www folder?

like image 292
Jayr Motta Avatar asked Sep 27 '22 09:09

Jayr Motta


1 Answers

According to the latest Ionic-Cli documentation, if you want any gulp tasks to run before the app is served, add a serve:before task to the gulpfile.js file in your project root. In your case this would be:

gulp.task("serve:before", [
    "styles",
    "source",
    "watch"
]);
like image 138
Sam Avatar answered Oct 12 '22 21:10

Sam