How To Use .env Variables In Webpack.js

Laravel Mix

APP_REGION=uk MIX_APP_REGION=${APP_REGION}

Using Variables In webpack.mix.js

require('dotenv').config();
process.env.APP_REGION
mix.js('resources/js/' + process.env.APP_REGION + '.js', 'public/assets/js/region.js').version()

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store