Run gulp task before ionic serve/build

I’m trying to execute a gulp task before “ionic serve” command. I’ve tried the solution provided here:

My ionic.config.json file:

  "name": "APP",
  "app_id": "",
  "v2": false,
  "typescript": false,
  "watch": {
    "sass": ["scss/**/*.scss"],
    "html": ["www/**/*.html"],
    "livereload": [

and I’ve added this to my gulpfile.js:

gulp.task('index', function () {
  var target = gulp.src('./www/index.html');
  // It's not necessary to read the files (will speed up things), we're only after their paths:
  var sources = gulp.src('./www/js/**/*.js', {read: false});

  return target.pipe(inject(sources, {relative: true}))

gulp.task('serve:before', ['index','default']);

But nothing is being executed when I run “ionic serve” command.

1 Like