Skip to content

Entrypoint File Question #450

Answered by ElMassimo
Fedrius asked this question in Q&A
Apr 1, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi Paul!

It's usually fine to have a single entrypoint, and let Rollup figure out the best way to split the bundle.

Something that you can do to have a more flexible setup is to allow the bundle to split each page in a separate chunk, by using dynamic imports:

if (location.pathname === '/admin/dbadmin')
  import('@pages/admin/Dbadmin.vue').then(mod => createApp(mod.default).mount('#sl_vue_dbadmin'))

You could generalize this by using a declarative approach such as adding data-app="admin/Dbadmin" to the element where each app should be mounted, using import.meta.glob to import all pages, then use the attribute to mount the corresponding Vue app:

const pagesByFilename = import.meta.glob('@p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Fedrius
Comment options

Answer selected by Fedrius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants