Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: read env in vite.config.ts #3532

Closed
wants to merge 1 commit into from
Closed

Conversation

ilaipi
Copy link

@ilaipi ilaipi commented Jan 10, 2024

General

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

  • 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)
  • 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.

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

@ilaipi
Copy link
Author

ilaipi commented Jan 10, 2024

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

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

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

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

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

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

@wangjue666
Copy link
Member

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

@ilaipi
Copy link
Author

ilaipi commented Jan 11, 2024

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

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

@wangjue666
Copy link
Member

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

@ilaipi
Copy link
Author

ilaipi commented Jan 12, 2024

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

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

@DesignHhuang
Copy link
Contributor

DesignHhuang commented Mar 4, 2024

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

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

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

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

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

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

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

@DesignHhuang
Copy link
Contributor

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

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

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

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

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

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

image

@jinmao88 jinmao88 closed this May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants