-
Notifications
You must be signed in to change notification settings - Fork 29
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
refactor(index.html): update DNS prefetch domains to *.gopluscdn.com
#928
Conversation
Signed-off-by: Aofei Sheng <aofei@aofeisheng.com>
The PR environment is ready, please check the PR environment [Attention]: This environment will be automatically cleaned up after a certain period of time., please make sure to test it in time. If you have any questions, please contact the builder team. |
<link rel="dns-prefetch" href="https://upload-na0.qiniup.com" /> | ||
<link rel="preconnect" href="https://builder-static.goplus.org" crossorigin /> | ||
<% if (NODE_ENV === 'production') { %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我想起来部署到测试环境时,NODE_ENV
应该也是 production
..
https://vitejs.dev/guide/env-and-mode.html#node-env-and-modes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好吧,那其实 vite.config.ts
里的 mode
也是有点小问题的,应该也同样一直是 production
builder/spx-gui/vite.config.ts
Line 12 in dbdd6c7
const env = loadEnv(mode, process.cwd(), '') |
现在应该有两种解决办法,一种是再提供一个类似 build
的 build-dev
script,区别是它会设置 NODE_ENV
和 --mode development
另一种是在 .github/workflows/build.yml
里加上 echo "NODE_ENV=development" >> .env
第二种可能简单些,但是按 https://vitejs.dev/guide/env-and-mode.html#node-env-and-modes 里的意思更推荐第一种?
NODE_ENV
in.env
files
NODE_ENV=...
can be set in the command, and also in your.env
file. IfNODE_ENV
is specified in a.env.[mode]
file, the mode can be used to control its value. However, bothNODE_ENV
and modes remain as two different concepts.The main benefit with
NODE_ENV=...
in the command is that it allows Vite to detect the value early. It also allows you to readprocess.env.NODE_ENV
in your Vite config as Vite can only load the env files once the config is evaluated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
好吧,那其实
vite.config.ts
里的mode
也是有点小问题的,应该也同样一直是production
嗯,从充分利用 vite 的能力来说是的,我之前都没注意它还能这样自动 load 不同的 env 文件..
第二种可能简单些,但是按 https://vitejs.dev/guide/env-and-mode.html#node-env-and-modes 里的意思更推荐第一种?
我也倾向第一种,之前在 .github/workflows/build.yml
里 echo 的做法总感觉怪怪的;用第一种的做法的话,我们就可以把测试环境的 env 文件也直接提交在 spx-gui/
下,比在 .github/workflows/build.yml
里维护会好一点
不过是不是 build-staging
要比 build-dev
合适一点?我理解我们本地开发时才是 mode: dev,我们部署的测试环境更接近 mode: staging?
NODE_ENV=development vite build --mode development
另外我不确定这里的 NODE_ENV
& mode
会不会影响 vite build 本身的行为,以前用 webpack 的时候,如果 env 不是 production 就可能不做类似 compression 这种优化;我们预期应该是 staging 跟 production 的 vite 行为完全一致,只是那个配置、环境变量值不同
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
另外我不确定这里的
NODE_ENV
&mode
会不会影响 vite build 本身的行为
又看了一遍文档,没提,应该是不会影响
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
细节还不少,所以单独开了个 issue 追一下这个问题 #929
No description provided.