Skip to content

Commit

Permalink
fix: try using a single extra component chunk
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Aug 31, 2023
1 parent 306e972 commit 44e0c47
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ if (process.server) {
</template>
<!-- Mobile panel -->
<template v-if="$route.path !== '/'" #panel>
<LazyUDocsSearchButton size="md" class="w-full mb-4" />
<LazyUNavigationTree :links="mapContentNavigation(navigation)" default-open :multiple="false" />
<UDocsSearchButton size="md" class="w-full mb-4" />
<UNavigationTree :links="mapContentNavigation(navigation)" default-open :multiple="false" />
</template>
</UHeader>
<NuxtLayout>
Expand Down
17 changes: 16 additions & 1 deletion docs/modules/components-chunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ export default defineNuxtModule({
'Markdown',
])

const globals = new Set<string>()

nuxt.hook('vite:extendConfig', config => {
config.build = defu(config.build, {
rollupOptions: {
output: {
manualChunks: {
'prose': [...globals]
}
}
}
})
})

nuxt.hook('components:extend', components => {
for (const component of components) {
if (nonGlobals.has(component.pascalName)) {
Expand All @@ -31,7 +45,8 @@ export default defineNuxtModule({
// With sync: 465KB, gzip: 204KB
// Without: 418KB, gzip: 184KB
if (component.global) {
component.global = 'sync'
globals.add(component.filePath)
component.global = true
}
}
})
Expand Down

0 comments on commit 44e0c47

Please sign in to comment.