Replies: 2 comments 3 replies
-
@slorber I believe you can consider disabling these optimizations by default when not building for production. There's no risk in that, is there? A Docusaurus dev build is already very different than a production build. PS: toggling this option made no difference in my build time, which remains around 20s after all 3.8 enhancements. |
Beta Was this translation helpful? Give feedback.
-
Glad I came across this thread this morning! I had a read of the referenced thread where a site with 11k pages was taking a long time to build. We're experiencing similar issues but with under slightly different CI conditions. We have a few hundred hand written documents in MD/MDX but also use the openapi plugin mentioned to generate more documents, in total 5980
We are using vercel to deploy which means our build containers are limited without upgrading from Pro to use more compute. After encountering scaling issues in our production builds in vercel after adding more versions of our openapi spec we refined the experimental_faster option to this:
This is paired with the some memory tweaks for the node process
The resulting build time is around 10 - 12mins. I think given the details listed in #11140 our build times are actually pretty good? Either way, I am conscious of the fact that this nonstandard approach might come back and bite us in the future when v4 is released and we're stuck in 3.8.0 New
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Docusaurus uses Webpack/Rspack to bundle your app, which by default uses
optimization.concatenateModules: true
for production builds.While working on Docusaurus v3.8 optimizations, we found out that this optimization:
If you have a very large site, and build time is a concern, you have the option to make builds faster, at the cost of slightly increased JS size.
A good idea could be to disable this optimization for local and deploy preview builds, but keep it only for production deployments.
Here's an example of how to do this when deploying on Vercel or Netlify:
Why not apply this by default?
By default, we believe it's better to favor UX (saving 3% JS for your site's visitors) rather than DX (reducing build times).
If you have a different opinion, it should be your responsibility to configure your optimizations accordingly. A good compromise is to only optimize for production deployment. Unfortunately, Docusaurus can't know if your
docusaurus build
is run for a test / deploy preview environment, or your real production deployment.Also, the Rspack team is aware of a possible bottleneck on this optimization that doesn't scale well when the number of docs increases. They will likely improve things in the future, making this trick less impactful. We could make this easier to configure, but we also don't want to introduce a first-party config option that we'll likely remove later.
Share your results
Please share below how much this tip improved your build time; this may help other users decide if they should try it too!
You can use
DOCUSAURUS_PERF_LOGGER=true
to print additional logs and know how much time it takes to bundle your app.I'll start with these results from a very large 11k docs website:
Before:
After:
Beta Was this translation helpful? Give feedback.
All reactions