Open dispbd opened 8 months ago
With the way Meteor-Vite is currently set up, I'm not sure if there would be much benefit to running a Vite minification step after the Meteor build.
The full Meteor-Vite build process looks something like the following:
vite.config.js
require()
function shipped to browsers in Meteor's client bundle. Essentially, the source code for those packages is omitted from the Vite bundle, it's handled something like an externalized dependency.esbuild
. I'll see if I can include some timings for this build step so we can determine whether there's any build time to be saved there.standard-minifier-js
and standard-minifier-css
take over if I'm not mistaken.When I first got into working on Meteor-Vite I was thinking it could act as a replacement to the Meteor build system. But it doesn't seem like Vite would be a good fit for that. Optimally, we would have Vite take care of both the client and server-side builds. But from what I can gather, Vite isn't really intended to be used as a build tool for the server. I imagine esbuild
would be the better option here.
Assuming most of the build time is spent after the Meteor-Vite build step has completed, the best solutions I can think of would be to either;
esbuild
-powered standard-minifier
package.meteor-vite
npm package ships with a standalone Vite plugin that takes care of most of the work previously done by the vite:bundler
Atmosphere package. Then it kind of is up to how long Meteor takes to build the server bundle.One important thing to check would be the Meteor client mainModule
file referenced in your package.json
. This file should ideally be empty apart from some Atmosphere package imports to ensure lazy-loaded packages won't be omitted from your client bundle.
If your Meteor client entry does have imports for application code, it's easy to end up with code that's included twice - once in your Meteor client bundle, and another in your Vite client bundle. Which will naturally slow down the build process and bloat your final production bundle.
Hello @JorgenVatle
We recently optimized the project and wanted to get rid of unnecessary dependencies. I thought that since Vite builds the client, the
standard-minifier-js
andstandard-minifier-css
packages are no longer needed (after all, they are only needed to minify the client). But it was not so. As I understand it, themeteor-vite
plugin does not minify third-party client code (packages folder, etc.). Moreover, as I understand it,meteor-vite
generally ignores the minification settings, since nothing changed when these settings were changed:How much do you think it makes sense to bypass the built-in minification (that is, minify the client code after the meteor build stage)? Will this give any advantage in build speed? or will the benefit be minimal due to the complexity of the assembly process and the structure of the assembled meteor code?