vue-vben-admin icon indicating copy to clipboard operation
vue-vben-admin copied to clipboard

feat: read env in vite.config.ts

Open ilaipi opened this issue 1 year ago • 7 comments

General

✏️ Mark the necessary items without changing the structure of the PR template.

  • [x] Pull request template structure not broken

Type

ℹ️ What types of changes does your code introduce?

👉 Put an x in the boxes that apply

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • [ ] This change requires a documentation update

Checklist

ℹ️ Check all checkboxes - this will indicate that you have done everything in accordance with the rules in CONTRIBUTING.

👉 Put an x in the boxes that apply.

  • [x] My code follows the style guidelines of this project
  • [x] Is the code format correct
  • [x] Is the git submission information standard?
  • [x] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my own code
  • [x] I have commented my code, particularly in hard-to-understand areas
  • [x] I have made corresponding changes to the documentation
  • [x] My changes generate no new warnings
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] New and existing unit tests pass locally with my changes
  • [x] Any dependent changes have been merged and published in downstream modules

ilaipi avatar Jan 10 '24 10:01 ilaipi

对于 proxy,我不知道大家都是咋用的,我一直的习惯是这样的。

对于纯前端开发来说,日常开发过程不需要起后端,对接的proxy地址,应该是统一提供的。

这种情况下,不管多少个纯前端开发,proxy地址是一样的,适合用 .env.development 之类的。

对于前端后端一起做的开发来说,每个人的后端启动的端口可能不一样,这时候proxy的地址就会不一样。

这种情况,在 .env.local 里写一个 proxy 地址,感觉比较合适,不需要提交到仓库。

这个pr是想让大家可以在 vite.config.ts 中读取到 .env.* 里的变量。

ilaipi avatar Jan 10 '24 10:01 ilaipi

前后端一梭子搞的话 压根不需要代理呀~

wangjue666 avatar Jan 11 '24 07:01 wangjue666

前后端一梭子搞的话 压根不需要代理呀~

前后端分离的话,不代理的话咋弄哦?

ilaipi avatar Jan 11 '24 13:01 ilaipi

后台服务开发环境下启用cors跨域是最简便的

wangjue666 avatar Jan 12 '24 01:01 wangjue666

后台服务开发环境下启用cors跨域是最简便的

这个不太认同,我觉得前端这里配置proxy是最“优雅”的

ilaipi avatar Jan 12 '24 10:01 ilaipi

对于 proxy,我不知道大家都是咋用的,我一直的习惯是这样的。

对于纯前端开发来说,日常开发过程不需要起后端,对接的proxy地址,应该是统一提供的。

这种情况下,不管多少个纯前端开发,proxy地址是一样的,适合用 .env.development 之类的。

对于前端后端一起做的开发来说,每个人的后端启动的端口可能不一样,这时候proxy的地址就会不一样。

这种情况,在 .env.local 里写一个 proxy 地址,感觉比较合适,不需要提交到仓库。

这个pr是想让大家可以在 vite.config.ts 中读取到 .env.* 里的变量。

不是,现在不能读取么?明明可以读取的哇。。。只是vue-vben-admin中把 target 写成固定的了,实际上完全可以从 env 读取啊。这个没什么需要改的。。。

DesignHhuang avatar Mar 04 '24 01:03 DesignHhuang

对于 proxy,我不知道大家都是咋用的,我一直的习惯是这样的。

对于纯前端开发来说,日常开发过程不需要起后端,对接的proxy地址,应该是统一提供的。

这种情况下,不管多少个纯前端开发,proxy地址是一样的,适合用 .env.development 之类的。

对于前端后端一起做的开发来说,每个人的后端启动的端口可能不一样,这时候proxy的地址就会不一样。

这种情况,在 .env.local 里写一个 proxy 地址,感觉比较合适,不需要提交到仓库。

这个pr是想让大家可以在 vite.config.ts 中读取到 .env.* 里的变量。

image

DesignHhuang avatar Mar 04 '24 01:03 DesignHhuang