Replies: 1 comment 2 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.
2 replies
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.
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