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()

--

--

--

Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Chart.js vs D3.js

npm ERR! Unexpected end of JSON input while parsing near [Solved]

https://youtu.be/hjFbQY9S0gM

Controlling Web Audio With React and Redux Middleware

Thou Shalt Respect The Redux State

Building A RESTful API: Express.js & MongoDB -Part 1

Persistence using redux-persists!

Understanding useEffect (Hook)

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
Paulund

Paulund

Software Developer

More from Medium

Overmind, the state management library you don’t know (yet) (but should)

Typing Builder Functions in TypeScript Featuring Styled Components

Setting up fool-proof linter rules

Component from NPM module cannot be used as a JSX component