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

Support production vite serve #271

Open
3 tasks done
amiller-gh opened this issue Aug 20, 2023 · 0 comments
Open
3 tasks done

Support production vite serve #271

amiller-gh opened this issue Aug 20, 2023 · 0 comments

Comments

@amiller-gh
Copy link

Is your feature request related to a problem? Please describe.

Currently, vite-plugin-checker will kill the process if NODE_ENV === 'production', regardless of the vite command used to start the build.

We have a use case in our application development flow where we want to run our vite dev server in "production" mode to hit up a production deployed canary service.

Other frontend build processes will change the build in ways that will allow our application to hit production services we start the vite server with NODE_ENV=production vite --host --mode production, but if any typescript error is introduced in locally, then vite-plugin-checker kills the local preview server, interrupting the dev flow!

Describe the solution you'd like

It would be nice if vite-plugin-checker only threw a hard error if config.command === "build", instead of throwing whenever NODE_ENV === 'production'. This would technically be a breaking change, so if included, it should probably go behind an option flag.

Describe alternatives you've considered

  • Change our code to use a different flag from NODE_ENV to trigger our production build changes (would rather not – NODE_ENV is core to a lot of other plugins' automatic build choices, and this would likely become a rabbit hole)
  • Disable vite-plugin-checker for our yarn start:prod local vite server and instead rely on running our checks in yarn scripts (would rather not duplicate logic, and still get frontend lint/type errors even in prod mode).
  • Patch vite-plugin-checker with patch-package locally so we can move on with development! ;) (We're already doing this because this is a wonderful package that dramatically improves DX, but I'd love to get something upstream that would meet our needs!)

Additional context

It's a pretty small fix to accommodate this use case. Appears to be a two character change right here: https://github.com/fi3ework/vite-plugin-checker/blob/e564641ac312eba95286b717177af27eb48bcf07/packages/vite-plugin-checker/src/main.ts#L103C9-L103C9

Changing this line to isProduction ||= config.isProduction && config.command === 'build' will only kill the process if NODE_ENV is production and the vite command is build.

This is the local change we made to continue using this package, but I'm sure if an official change is integrated that enables this, we'd likely want it behind a feature flag, and perhaps just narrowed to the serve command.

Validations

  • Read the docs.
  • Read the Contributing Guidelines.
  • Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.
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

No branches or pull requests

1 participant