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

Running Vite server during build breaks plugin assumptions #6364

Closed
1 task done
natemoo-re opened this issue Feb 24, 2023 · 3 comments · Fixed by #6368
Closed
1 task done

Running Vite server during build breaks plugin assumptions #6364

natemoo-re opened this issue Feb 24, 2023 · 3 comments · Fixed by #6368

Comments

@natemoo-re
Copy link
Member

natemoo-re commented Feb 24, 2023

What version of astro are you using?

2.0.12+

Are you using an SSR adapter? If so, which one?

N/A

What package manager are you using?

pnpm

What operating system are you using?

macOS

Describe the Bug

In #6238, we broke vite-plugin-pwa (and possibly others) because we started running a temporary Vite server during the build to load Content Collections. vite-plugin-pwa uses apply: 'serve' as a heuristic for running the dev server, which no longer works when we start a temporary server and pass all plugins to that server.

cc @userquin

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-kyecnu?file=integration.js,astro.config.mjs,package.json

Participation

  • I am willing to submit a pull request for this issue.
@userquin
Copy link
Contributor

userquin commented Feb 25, 2023

It is not heuristic, since Astro is using Vite from api, any configured plugin will run. Running Vite cli will filter plugins:
https://vitejs.dev/guide/api-plugin.html#conditional-application

Checking the code in Astro PWA repo to allow pwa run without any problem, it seems we also had also a problem with astro preview in older Astro versions with pwa integration, check my Last 2 PR in the repo, if command is preview we just prevent regenerate the sw in close hook.

@userquin
Copy link
Contributor

Maybe I can include a protection using command on configResolved hook in main plugin

@matthewp
Copy link
Contributor

I believe @bholmesdev plans to get rid of the special temporary Vite server and just load through the normal one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants