@websanova/vue-env

Simple environment Vue.js plugin.
1,088
Install
npm install @websanova/vue-env
Latest Version:0.6.2
Older releases:1
Last Updated:Mar 30, 2018
Links: npm
Maintainer: websanova

vue-env

A Simple plugin for loading an environment file.

Install

> sudo npm install @websanova/vue-env

Usage

For the simplest usage just include and the package will look for the local environment in the project root ./.env and for default environment specific files in ./src/env/ folder.

Vue.use(require('@websanova/vue-env'));

The env plugin will be available immediately after install.

Vue.env.get('SOME_VAR');

OR through the Vue instance.

this.$env.get('SOME_ENV_VAR');
this.$env.get('SOME_ENV_VAR', 'default value');

this.$env.set('key', 'val');
this.$env.set({key: 'val', key2: 'val2'});

Setting the Environment

The environment values can be initialized three ways and will override each other.

When setting the environment it must always be a valid JSON object.

1. Default on Install

Vue.use(require('@websanova/vue-env'), {APP_URL: 'https://example.com'});

2. App Presets

./src/
    ./env/
        ./local.js
        ./staging.js
        ./production.js

3. Local .env File

Must be located at root of project.

Note that this file is named .env but should return a valid Javascript object.

module.exports = {
    APP_URL: 'https://example.com'
};

Note

As a side note, it's generally not a good idea to commit the .env file. It's best to keep an example.env file that is committed instead.

Related Packages

vue-validator

Validator component for Vue.js

80,472 2,167
vue-grapesjs

GrapesJS plugin for Vue.js

1,703 21
vue-youtube

YouTube IFrame Player API wrapper

629,279 333
@marvr/storyblok-rich-text-vue-renderer

Vue.js plugin for Storyblok's rich-text renderer

81,454
vue-sorted-table

A Vue.js plugin to sort table content.

25,501 33

Version History

Version Released Vue License
0.6.2
0.6.1
0.6.0
0.5.0 1.0.27
0.4.0 1.0.27