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

fix: pass env param to config function #19

Merged
merged 4 commits into from
May 3, 2022

Conversation

sajadhsm
Copy link
Contributor

@sajadhsm sajadhsm commented May 3, 2022

I was tracing the root cause for the unocss/unocss#874 and I think the problem is here:

https://github.com/antfu/unconfig/blob/be90fdb34230e924f1f773d12d15845edb1aa2b5/src/presets.ts#L35

A quick solution would be to pass an empty object to __unconfig_default() so the destructing would pass. I thought it would be better to make it configurable.

I did a little search and it sounds like the Rollup, Svelte, and Astro configs don't mind a parameter, so this should be safe to bypass the Vite special case.

src/presets.ts Outdated
/**
* Retwrite the config file and extract the options passed to plugin factory
* (e.g. Vite and Rollup plugins)
*/
export function sourcePluginFactory(options: SourcePluginFactoryOptions) {
export function sourcePluginFactory(options: SourcePluginFactoryOptions, env: ConfigEnv = { command: 'dev' }) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be too specific, unconfig work not only for Vite. We should have parameters: any[] for user to pass in.

@antfu antfu merged commit 80485dc into antfu-collective:main May 3, 2022
@sajadhsm sajadhsm deleted the dynamic-config branch May 4, 2022 10:21
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.

2 participants