Use .env variables in your Javascript files with Laravel Elixir. Currently supports Webpack.
npm install laravel-elixir-env --save
or
yarn add laravel-elixir-env
- Laravel Elixir
- Laravel-elixir-webpack-official
Require the package in your gulpfile, after Elixir:
const elixir = require('laravel-elixir');
//...
require('laravel-elixir-env');
//...
Now you can access your variables in all the scripts that are packaged with Webpack like so:
process.env.VAR_NAME
Be careful with sensitive variables that can hold private information. Don't forget to recompile on all your environments.
If you like this, please star on GitHub!
Issues and Pull Requests welcome.
Laravel-elixir-env is licensed under The MIT License (MIT).