1

I have the following gulp function:

// TODO: Comment for production.
gulp.task('startServer', function() {
  return connect.server({
    root: './dist',
    port: 8080
  });
});

Every time I pull it to work on it locally, I have to uncomment the code and then comment it back when I push to prod. I have to do something similar to this in a few files. Is there a clever way to avoid this hassle and being able to pull/push code without having to comment/uncomment all of this for every single branch I work on?

Thanks.

Joe Berthelot
  • 725
  • 4
  • 16
  • 33

2 Answers2

1

You don't need to use gulp code to start server . You can run local and production server using express nodejs.

Dipten
  • 1,031
  • 8
  • 16
0

On your production server, the NODE_ENV environment variable should be set to production (NODE_ENV=production). So you can add a conditional to your gulp file to check whether you are running it on the production server or not:

if (process.env.NODE_ENV !== 'production') {
  gulp.task('startServer', function() {
    return connect.server({
      root: './dist',
      port: 8080
    });
  });
}
Mika Sundland
  • 18,120
  • 16
  • 38
  • 50