title: Set up Angular 6 environment variables from .env
body: <p>There's an angular 6 project using environment variables from <code>./project/src/environments/environment.prod.ts</code></p>
  <pre><code>export const environment = {
    production: true,
    testVar: 'gg',
  };
  </code></pre>
  <p>The backend for this project also has env variables in a <code>.env</code> file, so a lot of variable duplicate angular env variables. It would be nice to have something like</p>
  <pre><code>export const environment = {
    production: true,
    testVar: process.env.TEST_VAR
  };
  </code></pre>
  <p>, so I didn't have to duplicate variables.</p>
  <p>ie</p>
  <p>I'd like to parse variables from a <code>.env</code> file and assign their values to angular env variables during typescript compilation on the server.</p>
  <p>How can this be done?
  Maybe with webpack?</p>
  <p><strong>UPDATE</strong></p>
  <p>Some clarification. My .env file contains no json. It looks like this:</p>
  <pre><code>TEST_VAR=1
  </code></pre>
  <p><strong>UPDATE</strong></p>
  <p>Since <a href="https://github.com/angular/angular-cli/wiki/eject" rel="noreferrer">ng eject is not available for Angular 6</a>, I don't seem to be able to hack into webpack config. Looks like deadend here.</p>
  <blockquote>
  <p>ng eject</p>
  <p>Overview</p>
  <p>Temporarily disabled.</p>
  <p>Ejects your app and output the
  proper webpack configuration and scripts.</p>
  </blockquote>