-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide chunk splitting for shared objects like sidebar and nav #3367
Comments
I am happy to work on a PR regarding this if someone could provide me an idea of where to look at. |
Try setting |
It did reduce the overall size from I compared the results with and without the flag. Sidebar and nav items did NOT go away as you told me. I noticed the following changes to a specific html file as an example: --- before/xorg-docs/README.html
+++ after/xorg-docs/README.html
@@ -7,7 +7,7 @@
<meta name="description" content="Modern looking documentation for X. Content ported from X.org (version 11, release 7.7).">
<meta name="generator" content="VitePress v1.0.0-rc.32">
<link rel="preload stylesheet" href="/assets/style.a3MijG5e.css" as="style">
+ <script type="module" src="/assets/chunks/metadata.8c95dd74.js"></script>
<script type="module" src="/assets/app.h1QJGMyB.js"></script>
<link rel="preload" href="/assets/inter-roman-latin.bvIUbFQP.woff2" as="font" type="font/woff2" crossorigin="">
<link rel="modulepreload" href="/assets/chunks/framework.7MjZCsaf.js">
@@ -155,7 +155,7 @@
</p></div></div></div></div></main><footer class="VPDocFooter" data-v-29e741fd data-v-604f3077> (omitted) </footer>
- <script>window.__VP_HASH_MAP__=JSON.parse(/* 347440 Characters Omitted */);</script>
</body>
</html> Would you think it helpful to have an option that leaves the sidebar and nav items for client side rendering? |
Can you try patching There is another potential optimization that can be done for space - an option to ditch the SPA routing - if the whole side is re-rendered every time one opens a page or clicks a link to open a page, we don't need JS files other |
It worked great! Here is a comparison for all 3 conditions:
I also noticed significant speedup for bundling. Memory pressure was reduced as well.In addition, here is what I expect the config to look like:import { defineConfig } from 'vitepress';
defineConfig({
defaultTheme: {
// Navbar does not change between routes,
// so we only need a switch between SSR and CSR
nav: "nav.json",
// option 1: pass a `json` file path as string
// so the entire component will be client only
sidebar: "docs/index.sidebar.json",
// option 2 and 3: pass an object, with EACH entry configurable
sidebar: {
// Compatible with the original config
"/a/": {
text: "I want full SSR",
items: ["/a/page-1", /* ... */]
},
// option 2: Server side render the skeleton,
// and lazy fetch items
"/b/": {
text: "I want partial SSR, items shall be fetched when uncollapsed",
items: "docs/b/items.json",
collapsed: true,
},
// option 3: Client side render on **route match**,
// smaller chunks than option 1
"/c/": "docs/c/sidebar.json",
},
}
}) Or we can provide a wrapper like
|
Is your feature request related to a problem? Please describe.
After addressing the problem of memory overflow (issue #3362, pr #3366), I ended up producing a bundle that, although worked fine, turned out to be very large in size. Especially when compared to the original content size.
I investigated the produced html source tree and found each of them contains a copy of their corresponding navbar and sidebar, parsed into html template.
Describe the solution you'd like
Instead of hard-coding the sidebar (and maybe the navbar) as html templates into each entry file, provide a configuration switch to fall back to client side rendering with their data chunked separately as JSON files.
Describe alternatives you've considered
Not applicable
Additional context
To provide an idea of the scale of size, here is a summary of related objects in my project:
nav
objectsidebar
objectAnd here is a link of the deployed site: x.z-yx.cc
Validations
The text was updated successfully, but these errors were encountered: