title: Get environment variable defined in Linux bash to webpack
body: <p>I have checked out tons of SO questions about "environment variables in webpack" using e.g. the DefinePlugin:</p>
  
  <pre><code>new webpack.DefinePlugin({'ENV': JSON.stringify('staging')})
  </code></pre>
  
  <p>but I cannot for the life of me find a way to inject an environment variable defined in the linux bash shell, instead of using the hard coded <code>staging</code> string</p>
  
  <p>In my production and staging environements I have variables such as <code>$ENV</code> and <code>$API_KEY</code> defined, and I want to use their values in my webpack / ReactJs code. </p>
  
  <p><strong>Edit</strong> </p>
  
  <p>I notice, if I run the a webpack command from cli:</p>
  
  <pre><code> $ ENVIRONMENT=staging
   $ node_modules/.bin/webpack -p
  </code></pre>
  
  <p>And in my webpack.config.js file defines </p>
  
  <pre><code> new webpack.DefinePlugin({'ENV': JSON.stringify(process.env.ENVIRONMENT)})
  </code></pre>
  
  <p>This does not work (ENV is undefined in my JS code),</p>
  
  <p>However, if I run it on the same line, it seems to work - ENVIRONMENT seems to be available in the webpack.config.js file:</p>
  
  <pre><code>$ ENVIRONMENT=staging node_modules/.bin/webpack -p
  </code></pre>
  
  <p>So I would really like to make this work without having to define the ENVIRONMENT variable on the same line as the webpack command.</p>