vite-plugin-checker
vite-plugin-checker copied to clipboard
Support production `vite serve`
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 ouryarn 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
withpatch-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
- [X] Read the docs.
- [X] Read the Contributing Guidelines.
- [X] Check that there isn't already an issue that asks for the same feature to avoid creating a duplicate.