14

I am using angular-cli in my project.I want to add some gulp tasks for deployment. Is it possible for me to call "ng build" from inside a gulp task ?

Vinz and Tonz
  • 3,487
  • 5
  • 21
  • 32

1 Answers1

18

you can use child_process to make a command line call:

var exec = require('child_process').exec;

gulp.task('build', function (cb) {
  exec('ng build', function (err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    cb(err);
  });
})

see also here: Running a shell command from gulp for other solutions.

Community
  • 1
  • 1
dokkis
  • 366
  • 2
  • 8
  • 3
    Don't forget to navigate to project folder (if your **gulpfile** isn't in the same folder): `exec('cd ./../client && ng build', function(...` – Gil Epshtain Aug 19 '19 at 08:11