Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Use .env variables in Javascript with Laravel Elixir

License

Notifications You must be signed in to change notification settings

appstract/laravel-elixir-env

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel Elixir Env

NPM version

Use .env variables in your Javascript files with Webpack in Laravel Elixir.

Installation

npm install laravel-elixir-env --save

or

yarn add laravel-elixir-env

Requirements

  • Laravel Elixir
  • Laravel-elixir-webpack-official

Usage

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 packed with Webpack like so:

process.env.VAR_NAME

Optionally, you can set the path of the default .env file or set any dotenv configuration option like so:

require('laravel-elixir-env').config({ path: 'my-folder/.env' });

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.

Contributing

Contributions are welcome, thanks to y'all :)

About Appstract

Appstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on Medium. You can follow us on Twitter, buy us a beer or support us on Patreon.

License

Laravel-elixir-env is licensed under The MIT License (MIT).