title: Using Grunt to preprocess and replace environment variables
body: <p>I have an angular app setup that's using grunt, but I'd like to be able to use grunt as a preprocessor to replace variables and I haven't been able to find anything that matches my needs. </p>
  
  <p>For instance, if I change the name of my main app module to "someAppName" in a config file, I'd like to just use something like "ENV.APP_NAME" in various html and js files and have that replaced by an appropriate value for that environment. </p>
  
  <p>Ideally I'd like to have a config file somewhere along these lines, either as a .json file or using module.exports to expose an object, which specifies values for different environments:</p>
  
  <pre><code>{
      APP_NAME:{
          dev: "someAppDev",
          prod: "someApp"
      },
      API_BASE:{
          dev: "localhost:8000/",
          prod: "https://www.some-site.com/api/"
      }
  }
  </code></pre>
  
  <p>and then I could create a grunt task and pass it either "dev" or "prod" to have it run the preprocessor and replace each instance with the corresponding value. I've found this <a href="https://github.com/STAH/grunt-preprocessor" rel="noreferrer">https://github.com/STAH/grunt-preprocessor</a> but the examples are confusing and I don't think it's quite what I'm looking for.</p>
  
  <p>Is there anything like this that allows you to create preprocessed environment variables and read them from an external config file, or am I forced to build my own grunt plugin? Has anyone achieved something similar with grunt?</p>
  
  <p>EDIT: I've begun building a grunt plugin for this specific task, once it's done and tested I'll post it up on npm</p>