Coder Social home page Coder Social logo

How to use vue plugin about vike-vue HOT 6 CLOSED

vikejs avatar vikejs commented on September 21, 2024
How to use vue plugin

from vike-vue.

Comments (6)

lourot avatar lourot commented on September 21, 2024 1

Hey @Jimmyzm, thanks for reaching out. The easiest way to get started is to either copy an example or to scaffold a new project using https://batijs.github.io/

Here you can see how the examples glue together Vike (vite-plugin-ssr) with vitejs/plugin-vue: https://github.com/vikejs/vike-vue/blob/main/examples/basic/vite.config.ts

Here is where vike-vue gets plugged into Vike: https://github.com/vikejs/vike-vue/blob/main/examples/basic/pages/%2Bconfig.h.ts#L17

Let me know if anything is unclear. Recently we decided to reduce the readmes to a bare minimum and have them point at https://vite-plugin-ssr.com/ but thanks to this issue and after a conversation with @brillout, we now think the readmes of vike-vue, vike-react and vike-solid should be more elaborated. I'll keep this issue open and work on that (FYI @magne4000)

from vike-vue.

Jimmyzm avatar Jimmyzm commented on September 21, 2024

@AurelienLourot , thanks for the reply, what I mean is not about the vitejs/plugin-vue, it's about the plugins made for the vue ecosystem, the usage is here, they need the app instance to take effect before mounted.

from vike-vue.

lourot avatar lourot commented on September 21, 2024

Ah right, that's not possible yet. I didn't think of it, thanks a lot. I'll add a config option for that.

from vike-vue.

lourot avatar lourot commented on September 21, 2024

@Jimmyzm I have now implemented a vuePlugins option that takes a list of plugins with their respective options.

Note

It plays nicely with the ssr option: if you want SSR it will install the plugin both on the server and on the client. If you don't want SSR it will install it only on the client.

I have created an example on how to install a plugin: https://github.com/vikejs/vike-vue/blob/main/examples/with-vue-plugin/pages/%2BvuePlugins.ts

I still need to:

  • Release a new vike-vue version so you can make use of that
  • Properly document all this
  • Improve the example to install a real plugin instead of a dummy one

Let me know if there is anything else

from vike-vue.

Jimmyzm avatar Jimmyzm commented on September 21, 2024

@AurelienLourot thanks a lot! I just found if I import plugins at the +config.h.ts file with the vuePlugins option, It does not work at all because of the doc I found. Not re-exported imports

from vike-vue.

lourot avatar lourot commented on September 21, 2024

Indeed it's easier to create a +vuePlugins.ts file than to extend +config.h.ts. Vike will simply detect +vuePlugins.ts and use its return value as vuePlugins config option. This is true for any +<something>.ts file, by the way, except the special +config.h.ts file.

from vike-vue.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.