Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to switch Vue.js to production mode in Laravel?

Since Vue.js is comes already installed in Laravel, I'm not sure how to set it to production mode.

When I launch my website I get the message in console:

You are running Vue in development mode. Make sure to turn on production mode when deploying for production.

like image 634
Dasonic Avatar asked Sep 30 '19 11:09

Dasonic


2 Answers

Just build your assets using “npm run production”

like image 92
Thiago Barcala Avatar answered Nov 01 '22 20:11

Thiago Barcala


Method 1

npm run production

Method 2 In Laravel, add an environment variable in laravel configuration and based on the load the Vue configurations in the run time.

Define: MIX_ENV_MODE=production

Usage: process.env.MIX_ENV_MODE

And finally, add this code in any of your configuration script files

if (process.env.MIX_ENV_MODE === 'production') {
    Vue.config.devtools = false;
    Vue.config.debug = false;
    Vue.config.silent = true; 
}
like image 26
ptheodosiou Avatar answered Nov 01 '22 20:11

ptheodosiou