title: Laravel 5.8. How use variable of .env file in webpack.mix.js
body: <p>I did the following in .env file:
  APP_ENV=production
  MIX_APP_ENV="${APP_ENV}"</p>
  
  <p>In webpack.mix.js file:
  const APP_ENV = process.env.MIX_APP_ENV;</p>
  
  <p>Using the if else operator, I checked that nothing was assigned to the APP_ENV variable.
  I need to do the following - depending on the environment, compile sass and js files into a specific folder.</p>
  
  <p>I'm trying to do the following, but nothing works:</p>
  
  <pre><code>const APP_ENV = process.env.MIX_APP_ENV;
  
  if (APP_ENV == 'dev' || APP_ENV == 'production') {
      mix
          .js('resources/js/app.js', 'js')
          .sass('resources/sass/app.scss', 'css')
          .version();
  } else {
      mix
          .setPublicPath('public/build')
          .setResourceRoot('/build/')
          .js('resources/js/app.js', 'js')
          .sass('resources/sass/app.scss', 'css')
          .version();
  }
  </code></pre>