Skip to content

sidebar配置需要优化 #3933

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

Closed
4 tasks done
virskor opened this issue Jun 3, 2024 · 4 comments
Closed
4 tasks done

sidebar配置需要优化 #3933

virskor opened this issue Jun 3, 2024 · 4 comments

Comments

@virskor
Copy link

virskor commented Jun 3, 2024

Is your feature request related to a problem? Please describe.

当sidebar配置因为文件目录较多时,sidebar会被打包进入所有页面的HTML中,这将导致__VP_HASH_MAP__过大。

Describe the solution you'd like

希望根据目录配置sidebar,打包时,仅引入目录下的sidebar配置文件,避免注入到所有页面的__VP_HASH_MAP__中

Describe alternatives you've considered

No response

Additional context

No response

Validations

@brc-dd
Copy link
Member

brc-dd commented Jun 3, 2024

Set metaChunk: true in your .vitepress config. It will extract that to separate file and won't exponentially increase your size.

@chenyaowen123
Copy link

我也遇到了这个问题,页面较多时建议开启比较好,当我设置了 metaChunk: true,这让我的打包文件直接从500M降低至200M。这个配置比较有用,但是文档可能不够突出,我也是找了一段时间才找到。

@virskor
Copy link
Author

virskor commented Jun 6, 2024

设置metaChunk: true只是把sidebar打包的文件单独抽离到一个JS中去,虽然很简单解决了这个问题但是只能称为优化,因为核心的解决因该是每个目录的sidebar仅影响该目录下生成的文件,而不打包到其他路径的文件中去。这样即便1000个目录100000个sidebar menu,打包后每个目录的文件也很小,实际请求只会涉及当前目录的。

@brc-dd
Copy link
Member

brc-dd commented Jun 27, 2024

Duplicate of #3367

@brc-dd brc-dd marked this as a duplicate of #3367 Jun 27, 2024
@brc-dd brc-dd closed this as completed Jun 27, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants