in Laravel

How To Use .env Variables In Webpack.js

In this tutorial we're going to learn how we can use our .env variables inside the webpack.js config. The benefit of this is that we can now build the frontend assets based off variables in the application.

This is perfect for the example of when you have a different javascript file based of an variable. Maybe you have a cross region application where you have a uk.js file and a us.js file, you'll use the APP_REGION environment variable to decide

Upgrade to access all content on Paulund

Members unlock all tutorials and snippets

Access to all downloadable content

Access to code examples before others

Sign Up Now

Already a member? Login here

Subscribe To The Weekly Newsletter

Get weekly updates to your email