-
Notifications
You must be signed in to change notification settings - Fork 7
Vugel support for Vite #2
Comments
Hm, to use Vugel you need to use a custom compiler, so it would depend on being able to register a custom compiler for Vite. Another option would be using it like this: https://codepen.io/basvanmeurs/pen/vYNGRGP?editors=1010 (so with a custom render function) Edit: note that the |
Thanks @RobbinBaauw I have also created an issue on Vite side. May I ask, if |
This is added in the following PR: vuejs/vue-loader#1645 Didn't know of custom blocks, am trying to figure out a way to make it possible that way! I'm almost there Edit: here's the repo: https://github.com/RobbinBaauw/CustomCompilerBlock. I think the only thing that is in the way is the fact that import { createVNode as _createVNode, openBlock as _openBlock, createBlock as _createBlock } from "vue" This gives the following error: ` Edit 2: Btw, an important part of getting this to work in Vite is having proper support for ESM. Adding that to Vugel and its dependencies as well. |
Added ESM support :) |
@RobbinBaauw great stuff. Now when you made it work with Vite via custom block is this better than original |
I don't think so. The way I implemented this custom block (for now only for Vite but it should be doable similarly for vue-loader) is by overwriting the render function. I think this is quite a hack, if you for example add a Another issue is a bit less fundamental: I had some ESM problems with Vue (same as in my last comment), so I made it a hardcoded path. I don't have the time nor enough knowledge on ESM to improve this currently. Any ideas? To conclude: for development with Vite this should be plenty, but when actually putting an app in production I wouldn't really want to use this, hence I hope the vue-loader thing is going to get merged and a similar setting for Vite might be better too. |
Something like this could also work: RobbinBaauw/vite@9f76f26 |
@RobbinBaauw this is really cool stuff. Will be good to discuss both these approaches on Vite repository and probably worth to proceed with pull request to get more feedback. |
@RobbinBaauw Seems like we have a green light now. Support for custom compiler options have just been added to vite and it's rollup plugin. Here it is. |
Great! Then we have vuejs/rollup-plugin-vue#368, vuejs/vue-loader#1645 and vitejs/vite#488 |
Closing, feel free to reopen if you have any more questions. |
@RobbinBaauw will be probably also great to get the example you had reimplemented with new way provided by latest vite change, to make sure all holds together and nothing was missed. I have used that example yesterday to put some basic demo together, but was stuck with broken i have to say, this is all really amazing stuff. I was overjoyed when managed to get vugel working in my simple vue-vite demo yesterday. To have both DOM/Canvas/WebGL updates controlled by Vue reactivity this opens huge amount of new possibilities. Once this becomes stable I am sure there will be plenty of applications using this. Currently to make canvas changes in Vue application is like taking cold shower, you have to leave comfort of data binding provided by vue and do things old way. This will allow for the same DSL used for DOM by Vue to be used also for Canvas/WebGl. Really shows power of Vue3 and also have to say Tree2D/Vugel seems to be very fast. Kudos to everyone who made this possible @RobbinBaauw, @basvanmeurs, @yyx990803, @underfin and everyone else. |
I think we can convert our example repository to Vite once vitejs/vite#488 gets merged. You can see our current webpack config there as well. It is indeed very fast, we are using it internally to build a new product (which is where most of the testing of Vugel will come from, as we don't have a test suite on this repo) and we have been surprised as to what is possible. We might be able to publish part of this product as a showcase of Vugel in the future. |
Hi guys! I'm working on making a Pixi.js renderer for Vue. Since it's very convenient to have HTML + canvas rendered within one app, it should work with HTML elements. These PRs you listed seem very helpful, just they're not merged for a very long time. Is there anything moving on there? @RobbinBaauw do you know anything about |
It seems that you'll have to write your own plugin for Vite: https://github.com/vitejs/vite/tree/main/packages/plugin-vue#options |
Thanks, will check it out 👍 |
This looks really interesting and works great, but only webpack is supported via vue-loader. It would be great if it could work with Vite.
Thanks
The text was updated successfully, but these errors were encountered: