Open jplhomer opened 2 years ago
@frandiox — in the Plugin system you're exploring, we should follow through on this and remove the vite config file — though it would be nice to be able to eject this if necessary
@benjaminsehl Yes, I've had this in mind for a while and some of the recent changes will make this possible. This will be implemented after the plugins.
One of the reasons I'm trying to introduce plugin/vite.js
and so on is basically to remove vite.config.js
. Plugins will be able to pass optimizeDeps
and similar without the user doing anything.
Eventually, we will be able to remove vite.config.js
and allow users to create it to optionally add their own Vite config without doing anything Hydrogen-related in that file. In this case, it wouldn't even be considering "ejecting" since it's a completely optional file they add on their own.
Hydrogen is powered by Vite.
On the surface, it looks a lot like a standard Vite project, because we have a
vite.config.js
file with a simplehydrogen()
plugin.However, this is misleading:
To solve these problems, we should consider removing vite.config.js from the starter template, and adding a
vite
property tohydrogen.config.js
, which was introduced in #1065.This allows the developer to override certain Vite settings and apply plugins, but it's clear that the ability to customize Vite is merely an escape hatch allowed by Hydrogen and not a core expectation. This is similar to the behavior Next.js uses to customize Webpack.
To do this, we likely need to switch to a dedicated
hydrogen dev
andhydrogen build
command rather than rawvite
andvite build
. There are additional benefits to this, too, like being able to provide better error messaging. I believe @cartogram is already working on this specific thing.