Closed condorheroblog closed 11 months ago
I can't think of a way to implement SSG as a Vite plugin. The SSR examples provided by the Vite official are also outside of the Vite ecosystem, using Vite API to implement SSR.
Regarding vite-ssg, the reason it doesn't replace the dev command is because it uses CSR (which is Vite's default behavior) during development. Vite-ssg doesn't do anything during development. Personally, I hope to provide SSR (Server-Side Rendering) during development to ensure consistency between development and production as much as possible.
You can see: https://github.com/Daydreamer-riri/vite-react-ssg?tab=readme-ov-file#use-csr-in-development-environment
Regarding your suggestion, in the situation where we cannot implement vite-react-ssg as a Vite plugin (as I believe), we can strive to enhance the CLI functionality of vite-react-ssg.
I hope vite-react-ssg is just a plugin for Vite. It should not replace my build command, neither in theory nor in practice:
I wish to keep my original build command:
Instead of being replaced by the following
This replacement will lose the function of Vite itself
vite --port 3000
/vite-plugin-fake-server/
and openshttp://localhost:9000/
in the browser, it will automatically redirect tohttp://localhost:9000/vite -plugin-fake-server/
If vite-react-ssg can be run as a plugin, I also recommend having a parameter like enable to set whether to
enable
the plugin.I have some preliminary thoughts and suggestions that I hope could contribute to improving your plugin.
I genuinely appreciate your plugin🙏.