vue-cli-plugin-env-validator

1.0.2 • Public • Published

Vue CLI Env Validator Plugin

A Vue CLI Plugin to validate Environment Variables with type checking like Vue Props.

npm Build status Test coverage

Install

vue add env-validator

Usage

// vue.config.js
 
module.exports = {
  pluginOptions: {
    envValidator: {
      schema: {
        VUE_APP_FIREBASE_API_KEY: {
          type: String,
          required: true
        },
        VUE_APP_ENABLE_FIREBASE_AUTH: {
          type: Boolean,
          required: true
        },
        VUE_APP_FIREBASE_AUTH_PWD_MIN_LENGTH: {
          type: Number,
          required: true
        }
      }
    }
  }
}

Usage with a prefix

// vue.config.js
 
module.exports = {
  pluginOptions: {
    envValidator: {
      prefix: 'VUE_APP_',
      schema: {
        FIREBASE_API_KEY: {
          type: String,
          required: true
        },
        ENABLE_FIREBASE_AUTH: {
          type: String,
          required: true
        },
        FIREBASE_AUTH_PWD_MIN_LENGTH: {
          type: Number,
          required: true
        }
      }
    }
  }
}

License

Under the MIT license. See LICENSE file for more details.

Package Sidebar

Install

npm i vue-cli-plugin-env-validator

Weekly Downloads

51

Version

1.0.2

License

MIT

Unpacked Size

4.61 kB

Total Files

5

Last publish

Collaborators

  • demsking