vue-cli-plugin-env-validator

Validate Environment Variables with type checking like Vue Props

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
vue-cli-plugin-env-validator
1.0.24 years ago4 years agoMinified + gzip package size for vue-cli-plugin-env-validator in KB

Readme

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.