I was trying to setup sage 10, which after a little bit of trial and error went fine. However when trying to setup vue with it I ran into a roadblock. I installed vue with this link @roots/bud-vue | bud.js
What do I need to do now? It feels like there’s a massive hole left in the documentation.
We’re using Sage 10 and Vue 3, and although I don’t have an example ready to share with you, hopefully the following will help…
One of the great things about bud and bud-vue is it just works out of the box. There’s no Sage / Bud-specific hole in the documentation at all. In your ./resources/scripts/app.js file, you’re all ready to go. Just import your components, and any helper you need from vue, like createApp, and then kick it all off once the DOM is ready…
import domReady from '@roots/sage/client/dom-ready';
import { createApp } from 'vue';
import MyVueComponent from './components/MyVueComponent.vue';
domReady(() => {
const app = createApp(MyVueComponent);
app.mount('#mountpoint');
});
import.meta.webpackHot?.accept(console.error);
Does that help at all, or have I missed the point?
Thanks for the help Talss89. I guess my question now is how would I use these components in blade templates, is there anything else I need to do? My apologies if this sounds basic, I never did something like this.
No problem, and it’s a good question. Unfortunately there are a number of right answers, and it’s down to you to decide on what fits your use-case best.
One thing is always true: you’re going to want to load the JS, and mount the Vue app to an element.
Whether you use lazy loading, split your application into chunks or just load one big monolithic bundle and conditionally mount is up to you.
All of these are kind of confusing, while I barely get the point, I can’t convert it to working code. Is there maybe a way we could have a short 1 on 1 call. You seem to know a lot about sage, I on the other hand am barely keeping my head above water
Hi @Kruks - There are many other people with much more experience with Sage and the Roots ecosystem than I have, so if you have a specific question, the best thing to do would be to post it here with a detailed explanation and reproducible example, or perhaps support Roots with a sponsorship and reach out to the Discord community. Happy to talk though, I’ll DM.
Let’s leave this thread now to save going off-topic.