Reputation: 735
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.
Upvotes: 1
Views: 132
Reputation: 18939
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
});
});
}
Upvotes: 0
Reputation: 1066
You don't need to use gulp code to start server . You can run local and production server using express nodejs.
Upvotes: 1