Laravel Vue cannot load env variables

I’m trying to disable the Vue Devtools in production so i want inside the app.js to check if the APP_ENV variable is equal to production.

What i have done so far:

Inside webpack.mix.js


Inside app.js


if (process.env.APP_ENV === 'production') {
    Vue.config.devtools = false;
    Vue.config.debug = false;
    Vue.config.silent = true; 

Enviroment Variable


I read the documentantion about adding MIX_APP_ENV so i can inject the variable inside webpack but it didn’t also work.

Folder Structure:

d-----        01-Feb-21  10:31 PM                app
d-----        29-Jan-21  12:12 PM                bootstrap
d-----        29-Jan-21  12:12 PM                config
d-----        30-Jan-21  10:26 PM                database
d-----        16-Apr-21  10:49 PM                node_modules
d-----        29-Jan-21   1:14 PM                public
d-----        29-Jan-21  12:22 PM                resources
d-----        29-Jan-21  12:12 PM                routes
d-----        29-Jan-21  12:12 PM                storage
d-----        29-Jan-21  12:12 PM                tests
d-----        01-Feb-21   9:29 PM                vendor
-a----        29-Jan-21  12:12 PM            220 .editorconfig
-a----        16-Apr-21  10:45 PM            954 .env
-a----        29-Jan-21  12:14 PM            816 .env.example
-a----        29-Jan-21  12:12 PM            111 .gitattributes
-a----        29-Jan-21  12:12 PM            191 .gitignore
-a----        29-Jan-21  12:12 PM            181 .styleci.yml
-a----        29-Jan-21  12:12 PM           1686 artisan
-a----        01-Feb-21  10:41 PM           1793 composer.json
-a----        01-Feb-21  10:41 PM         282388 composer.lock
-a----        16-Apr-21  10:49 PM         531190 package-lock.json
-a----        16-Apr-21  10:49 PM           1103 package.json
-a----        29-Jan-21  12:12 PM           1202 phpunit.xml
-a----        29-Jan-21  12:12 PM           3780
-a----        29-Jan-21  12:12 PM            563 server.php
-a----        16-Apr-21  10:55 PM            578 webpack.mix.js


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

I figured out that you need to re-run npm run watch if it is already running, that was the actual issue.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x