# Run gulp task before ionic serve/build

**URL:** <https://forum.ionicframework.com/t/run-gulp-task-before-ionic-serve-build/94631>\
**Category:** ionic-v1\
**Created:** [June 16, 2017, 10:02am UTC](https://forum.ionicframework.com/t/run-gulp-task-before-ionic-serve-build/94631 "2017-06-16T10:02:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kno](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/kno/32/75729_2.png) [@kno](https://forum.ionicframework.com/u/kno)\
**Post date:** [June 16, 2017, 10:02am UTC](https://forum.ionicframework.com/t/run-gulp-task-before-ionic-serve-build/94631/1 "2017-06-16T10:02:17Z")

</div>

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

> [@Ionic CLI doesn't run gulp tasks on ionic serve](https://forum.ionicframework.com/t/ionic2-cli-doesnt-run-gulp-tasks-on-ionic-serve/49085/7):
>
> Hi, I think i found a solution for the issue. Just add this to your gulpfile.js gulp.task('serve:before', ['default']); That line tells the new ionic cli 2@beta to run the old ionic cli 1.x ‘default’ task before serving (before running ionic serve) Also you need to add a ionic.config.json file with this: { "name": "base\_project", "app\_id": "", "v2": false, "typescript": false, "watch": { "sass": ["scss/\*\*/\*.scss"], "html": ["www/\*\*/\*.html"], "livereload": [ "www/…

My ionic.config.json file:

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

```

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

```auto
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}))
    .pipe(gulp.dest('./www'));
});

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

```

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