You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
473 B

3 months ago
  1. const getBaseUrl = require('./getBaseUrl')
  2. const prefixRE = /^VUE_APP_/
  3. module.exports = function resolveClientEnv (options, raw) {
  4. const env = {}
  5. Object.keys(process.env).forEach(key => {
  6. if (prefixRE.test(key) || key === 'NODE_ENV') {
  7. env[key] = process.env[key]
  8. }
  9. })
  10. env.BASE_URL = getBaseUrl(options)
  11. if (raw) {
  12. return env
  13. }
  14. for (const key in env) {
  15. env[key] = JSON.stringify(env[key])
  16. }
  17. return {
  18. 'process.env': env
  19. }
  20. }