Support the ongoing development of Laravel.io →
Configuration Packages
Last updated 1 year ago.
0

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) {
    mix.less('app.less')
       .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.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Fry4u fry4u Joined 28 Jul 2015

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.