Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var gulp    = require('gulp');  
var replace = require('gulp-replace-task');  
var args    = require('yargs').argv;  
var fs      = require('fs');

gulp.task('replace', function () {  
  // Get the environment from the command line
  var env = args.env || 'localdev';

  // Read the settings from the right file
  var filename = env + '.json';
  var settings = JSON.parse(fs.readFileSync('./config/' + filename, 'utf8'));

// Replace each placeholder with the correct value for the variable.  
    patterns: [
        match: 'apiUrl',
        replacement: settings.apiUrl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment