Migrated to vuepress-community
VuePress uses dynamic import to load page components and layout components. Each component becomes a separate chunk, but their names are automatically generated, which is not conducive to subsequent tracking. vuepress-plugin-named-chunks
is a VuePress plugin for generating named chunks for page and layout components.
npm install -g vuepress-plugin-named-chunks
# OR
yarn global add vuepress-plugin-named-chunks
npm install vuepress-plugin-named-chunks
# OR
yarn add vuepress-plugin-named-chunks
module.exports = {
plugins: [
'named-chunks',
],
}
or
module.exports = {
plugins: {
'named-chunks': {
pageChunkName: page => 'page' + page.key.slice(1),
layoutChunkName: layout => 'layout-' + layout.componentName,
},
}
}
This plugin will inject some properties into context API.
context.pages
is an array ofPage
objects.page._chunkName
is the chunk name of the page component.
context.themeAPI.layoutComponentMap
is a map ofLayoutComponent
objects.layout.chunkName
is the chunk name of the layout component.
- type:
((page: Page) => string) | false
- default:
({ key }) => 'page' + key.slice(1)
A function that generates chunk name from Page
object.
- type:
((layout: LayoutComponent) => string) | false
- default:
false
A function that generates chunk name from LayoutComponent
object.