mix-env-file

0.1.1 • Public • Published

mix-env-file

Allows Laravel Mix to use to a specific .env file

By default mix only allows variables from a single file, .env, in the root of the project. This simple plugin will override the environment varibles from .env with a specified env file.

This is especially useful when building locally or on a build server then deploying to different locations.

Installation

$ npm install mix-env-file

or

$ yarn add mix-env-file

Usage

Update scripts in package.json to include a ENV_FILE environment variable:

"dev": "NODE_ENV=development ENV_FILE=./.env.test node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",

OR run npm/yarn with an environment variable:

 ENV_FILE=.env.production yarn run production

Then in webpack.mix.js file, require mix-env-file after laravel-mix.

let mix = require('laravel-mix');
require('mix-env-file');

// Then pass your file to this plugin
// If this is not set, this plugin won't do anything and the default .env variables will remain
mix.env(process.env.ENV_FILE);

...

License

MIT

Package Sidebar

Install

npm i mix-env-file

Weekly Downloads

3,587

Version

0.1.1

License

MIT

Unpacked Size

2.9 kB

Total Files

3

Last publish

Collaborators

  • johnwilhite