-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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: add async support for vite config file #2758
Conversation
This looks good. How would it work when using Edit: It could be used like import { defineConfig } from 'vite'
export default async ({ command, mode }) => {
const data = await asyncFunction();
return defineConfig({
// build specific config
})
} but it would be nice to have import { defineAsyncConfig } from 'vite'
export default defineAsyncConfig(async { command, mode }) => {
const data = await asyncFunction();
return {
// build specific config
}
}) That also type checks |
I think The really nice thing behind - export default config
+ export default defineConfig(config
- export default () =>
+ export default defineConfig(() =>
- export default async () =>
+ export default defineConfig(async () => |
There are two smart ways of handle this: https://stackoverflow.com/questions/27746304/how-do-i-tell-if-an-object-is-a-promise First would be to check if it's a promise, or second (and I think this is really smart ^^) just use |
@Shinigami92 We can just use |
Seems it's not my day 😆 and I'm thinking far to complicated |
@yyx990803 Anything else should I do? |
@xiaoxiangmoe if you would like to modify Edit: Ok, IMO we can merge this as is but it would be good to have that modification soon. We can use it like this until that time:
Note: Evan needs would need to approve this one. |
@patak-js I'm not sure if you're messing something up, but I would thing it would be this way 🤔: import { defineConfig } from 'vite'
export default defineConfig(async ({ command, mode }) => {
const data = await asyncFunction();
return {
// build specific config
}
} |
@Shinigami92 updated my wording, the code snippet was referring to how it can be used until we modify |
@yyx990803 Can you review it? |
Hey @xiaoxiangmoe, we are using GitHub's review requests when we need Evan's input so he can look at all the issues and PR that require his attention when he is focusing on Vite. There is no need to explicitly ping him with an extra message. |
Oh, I know. Sorry. |
Description
feat: add async support for vite config file
for example:
If the config needs to call async function, it can export a async function instead:
Additional context
What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following
fixes #123
).