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 plugin apply args when filtering #6601

Merged
merged 1 commit into from
Mar 21, 2023
Merged

Fix plugin apply args when filtering #6601

merged 1 commit into from
Mar 21, 2023

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Mar 20, 2023

Changes

vite-plugin-inspect relies on the command arg to return a value for apply. In Astro, it's 'dev' | 'build', but in Vite, it's 'serve' | 'build'.

This PR normalizes to Vite's convention before apply it to the plugin when we filter the plugins.

Testing

Tested manually with vite-plugin-inspect

Docs

n/a. bug fix.

@changeset-bot
Copy link

changeset-bot bot commented Mar 20, 2023

🦋 Changeset detected

Latest commit: 6b48989

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Mar 20, 2023
@@ -196,7 +196,7 @@ export async function createVite(
const applyToFilter = command === 'build' ? 'serve' : 'build';
const applyArgs = [
{ ...settings.config.vite, mode },
{ command, mode },
{ command: command === 'dev' ? 'serve' : command, mode },
Copy link
Member

Choose a reason for hiding this comment

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

nit: I think it's safer to hardcode "build". It prevents cases where in the future, we change build to another string, and it might not work anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was following the pattern at here too:

// Vite `command` is `serve | build`, but Astro uses `dev | build`
const cmd = command === 'serve' ? 'dev' : command;

I think it's unlikely we'll change the command name so it might be fine 🤔

@bluwy bluwy merged commit f112c12 into main Mar 21, 2023
@bluwy bluwy deleted the fix-pass-command branch March 21, 2023 04:06
@astrobot-houston astrobot-houston mentioned this pull request Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants