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

[Help] 在 electron/main 下对 process.env 使用点运算符导致编译后文件异常 #210

Closed
SaberA1ter opened this issue Jul 24, 2022 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@SaberA1ter
Copy link
Contributor

想给项目装上 eslint,在开启了 dot-notaion 下发现了一个编译上的问题。

原代码(electron/main/index)
const url = `http://${process.env['VITE_DEV_SERVER_HOST']}:${process.env['VITE_DEV_SERVER_PORT']}`

修改为
const url = `http://${process.env.VITE_DEV_SERVER_HOST}:${process.env.VITE_DEV_SERVER_PORT}`

编译过后(dist/electron/main/index)变成了
const url = `http://${{}.VITE_DEV_SERVER_HOST}:${{}.VITE_DEV_SERVER_PORT}`;

关于这块有什么解决办法吗,目前处理是关闭了 dot-notaion 保持原先 a['value'] 这类写法

@SaberA1ter SaberA1ter added the help wanted Extra attention is needed label Jul 24, 2022
@caoxiemeihao
Copy link
Member

caoxiemeihao commented Jul 24, 2022

This behavior is caused by the vite:define plugin inside Vite. A PR on this issue is currently under discussion.
vitejs/vite#8843

这个行为是由于 Vite 内部的 vite:define 插件引起的。关于这个问题的 PR 目前正在讨论中

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants