How to run production mode in vue.js with laravel ?
Method 1 :
In Laravel , Vue.js is included through NPM package and will be compiled as part of webpack in node stack. so while executing the npm assets compile command we need to mention it to compile in production mode. here is the command.
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.
Environment Variable Creation Guide refer : https://laravel.com/docs/5.6/mix#environment-variables
Define :
MIX_ENV_MODE=production
Usage:
process.env.MIX_ENV_MODE
In any of the scripts file make sure to add conditional execution of vue.js configurations as below :
if (process.env.MIX_ENV_MODE === 'production') {
Vue.config.devtools = false;
Vue.config.debug = false;
Vue.config.silent = true;
}