Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comment/Uncomment code based on condition

I have been using the gulp-remove-code plugin to remove the specific code from the source files, when I need to change the environment from staging to production or vice-versa. Most of the changed code is API keys and boolean flags. This is for JS, Python, and Yaml files.

The problem with the approach is that, I need to keep the original file at a separate place, since it removes the other environment code.

Instead of removing the code based on a variable, I want to comment or uncomment code, so that I can do an in-place gulp.dest() without having a separate file.

Is there any way to do it via 'gulp' or using the 'gulp-remove-code' plugin or any other plugin?

like image 903
noob Avatar asked Apr 19 '26 12:04

noob


1 Answers

I use npm module config for that purposes.

All you have to do is:

  • set NODE_ENV env variable
  • add config files with the same names as NODE_ENV variable
  • set NODE_CONFIG_DIR env variable

This approach is very convenient.

like image 190
Lazyexpert Avatar answered Apr 22 '26 00:04

Lazyexpert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!