Caching intermediate files during build #12943
Unanswered
kierangilliam
asked this question in
Q&A
Replies: 2 comments 1 reply
-
We're able to halve build times by wrapping plugins with:
The other half of the build time is spent on the calls: What strategies can we use to reduce the time spent processing |
Beta Was this translation helpful? Give feedback.
0 replies
-
Here's the
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using the
build
command programmatically. This command is called multiple times in production. My project has hundreds of files, and I want to enable incremental builds for production to speed up the process. I need a way to cache intermediate build steps to reduce the build time for subsequent builds.Whenever my server is deployed, I lazily build javascript bundles using Vite's
build
command. The server will immediately serve a cached bundle and then perform a rebuild in the background.Example:
GET /bundle?id=A
=> Returns a Javascript file from a persistent cache immediately. Builds a new version ofA
in the background and updates the cache.This has to happen lazily because there are thousands of different
id
s. I do not have the CI resources to pre-build all of these files. Many files only get accessed once a month, so rebuilding on each deployment (which happens once a day) would be a massive waste of time.Project Structure:
Server implementation (index.js):
I have a custom plugin that selects either A, B, C, or D depending on a query parameter.
myCustomPlugin
will resolveimport thing from 'virtual:component'
assrc/components/${id}.jsx
. Note that I cannot do dynamic imports for this setup.Whenever I call
build
, Vite will rebuild everything:node_modules
,src/routes
, etc.I've tried using
rollupOptions.cache
, but the caching doesn't seem to speed up the builds. I'm looking for a way to enable incremental builds for production without using the Vite development server when doing programmatic builds.Is there any recommended approach to achieve this? I'm open to suggestions on how to optimize my build process in this scenario.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions