Giter Site home page Giter Site logo

vue-env's Introduction

vue-env

A Simple plugin for loading an environment file.

Install

> npm install @websanova/vue-env

or

> yarn add @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.

vue-env's People

Contributors

websanova avatar brockreece avatar maxamante avatar gustawdaniel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.