Support the ongoing development of →
Configuration Packages
Last updated 2 years ago.

I came across your post trying to figure out this same thing just now. I have my working solution below.

I added a GOOGLE_MAPS_API_KEY= key to my .env file and then added the envify to the transform option of elixir's browserify function:

var envify = require('envify/custom'); // replace process.env.* variables with strings
var envs = require('envs'); // optional but clean look for loading from process.env.*
dotenv = require('dotenv').config(); // load .env file (from / root) into process.env.* variable

elixir(function(mix) {
       .browserify('app.js', null, null, { paths: 'vendor/laravel/spark/resources/assets/js', transform: [
           [ envify({ GOOGLE_MAPS_API_KEY: envs('GOOGLE_MAPS_API_KEY', '123abcnotarealkey') }) ]
       ] })
       .copy('node_modules/sweetalert/dist/sweetalert.min.js', 'public/js/sweetalert.min.js')
       .copy('node_modules/sweetalert/dist/sweetalert.css', 'public/css/sweetalert.css');

Last updated 7 years ago.

Sign in to participate in this thread!


Your banner here too?

Fry4u fry4u Joined 28 Jul 2015


We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 - All rights reserved.