title: Environment Variables not being set by Webpack
body: <p>Environment variables are not being passed through to the Webpack build.</p>
  <p><a href="https://github.com/tenfinney/webpack-env-var-test" rel="nofollow noreferrer">This repository</a> has our <a href="https://github.com/tenfinney/webpack-env-var-test/blob/main/webpack.config.ts" rel="nofollow noreferrer">current configuration</a> and demonstrates the problem.</p>
  <p>It runs the following script:</p>
  <pre class="lang-js prettyprint-override"><code>const p = (typeof process === 'undefined' ? null : process)
  console.log({
    process: p,
    env: p?.env,
    var: p?.env?.VITE_TEST_VAR,
  })
  </code></pre>
  <p>This prints:</p>
  <pre><code>{ process: null, env: undefined, var: undefined }
  </code></pre>
  <p>I have a <code>.env</code> file with the following contents:</p>
  <pre><code>VITE_TEST_VAR=testing_key
  </code></pre>
  <p>I have tried the following methods:</p>
  <pre class="lang-js prettyprint-override"><code>{
    new webpack.DefinePlugin({
      process: JSON.stringify({}),
      'process.env': JSON.stringify(process.env)
      'process.env.VITE_TEST_VAR': JSON.stringify(process.env.VITE_TEST_VAR)
      process: { env: { VITE_TEST_VAR: JSON.stringify(process.env.VITE_TEST_VAR) } }
      'process.env.VITE_TEST_VAR': process.env.TEST_VAR
      'VITE_TEST_VAR': JSON.stringify(process.env.VITE_TEST_VAR)
    }),
    new webpack.EnvironmentPlugin (['VITE_TEST_VAR']),
  </code></pre>
  <p>Nothing works. Any alternatives?</p>