Ran into the same propblem. Have you found any solution so far?
Jul 13, 2018
6
Level 10
How can Mix use different production environment variables?
I set up 2 simple pusher channel apps, 1 for dev and 1 for production.
.env
PUSHER_APP_ID=pusher_app_id
PUSHER_APP_KEY=pusher_app_key
PUSHER_APP_SECRET=pusher_app_secret
PUSHER_APP_CLUSTER=pusher_app_cluster
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
bootstrap.js
import Echo from 'laravel-echo'
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
encrypted: true
});
This worked fine in dev, but when I compile and push up to production it keeps the dev .env file variable values.
Can someone tell me how to get mix to keep using the dev .env file variable values in dev but then use production .env file variable values in production?
I have a hunch the solution lies with npm run production and npm run dev and I may need to add some code to webpack.mix.js , but I'm not sure. I'm hoping someone ran into this issue already and can let me know.
Thanks!
Please or to participate in this conversation.