Skip to content
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

build size #72

Open
freeman-lab opened this issue Jan 1, 2022 · 0 comments
Open

build size #72

freeman-lab opened this issue Jan 1, 2022 · 0 comments

Comments

@freeman-lab
Copy link
Member

freeman-lab commented Jan 1, 2022

I just noticed something about our build size that warrants further investigation. Because of this declaration in _app.js

import { LiveCode, Pre } from '@carbonplan/prism'
import Blockquote from '../components/blockquote'

const components = {
  code: LiveCode,
  pre: Pre,
  blockquote: Blockquote,
}

all pages in the resulting site have very large sizes (300kb+). By removing different components and rebuilding I confirmed LiveCode is the bulk of the problem. The syntax highlighting in just the Code component would be smaller, but still add a fair bit. This makes sense — with this configuration, all pages have LiveCode loaded whether or not they use it.

I think the right solution would be to move the MDXProvider into a page-specific wrapper here, and when we build the individual pages, pick which additional components to include based on page metadata. For example, we could have include

components: ['LiveCode', 'BlockQuote']

in the metadata to specify that a specific page needs these extra components. Open to alternatives, but we should solve this one way or another. No need for such large builds on otherwise tiny sites!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant