Support for external vue
See original GitHub issueIs your feature request related to a problem? Please describe.
I’m using vue.global.js
in rails application through unpkg link and having vue inside ViteJs application.
I would like to tell Vite to do not import vue from modules but make a reference to window.Vue. (use the external one)
Describe the solution you’d like It would be awesome to have code what allows us to modify modules resolution. eg.: vite.config.ts
alias: {
"vue": "window.Vue"
}
or any better alternative what allows us to use one global Vue.
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (4 by maintainers)
Top Results From Across the Web
Building external modules in VueJS - Pusher Blog
To build our external Vue module, we need to make sure it is one that can be reused across multiple projects and not...
Read more >How to Make Secure HTTP Requests with Vue and Express
TL;DR: In this article, you're going to build an Express API and then make API calls to it from an existing Vue.js application....
Read more >Add External Scripts - Gridsome
It is really easy to use any external or third-party JavaScript with Gridsome. Since Gridsome is built on Vue, any method of importing...
Read more >Composables - Vue.js
In the context of Vue applications, a "composable" is a function that leverages Vue's Composition API to encapsulate and reuse stateful logic. When...
Read more >VueJs vue-router linking an external website - Stack Overflow
For external links, just use <a href="..."> to point directly to whatever you're linking to. vue-router is only needed for internal links. – ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@yyx990803 Passing an external to
rollupInputOptions
won’t solve development mode. It still complains about presence of two Vue applications. Is there a way how to tell Vite to search Vue from Vue.global.js? Your code solves only bundling process.I had the same issue for React where the existing page had a global copy of React loaded, which I needed to use in my new ViteJS bundled component. Rollup externals worked perfectly for the production build, but in development Vite was sending a second instance of React, which results in errors from React:
This plugin looked like it should work around this issue: https://github.com/lceric/vite-plugin-resolve-externals
However unfortunately I had issues with the plugin (perhaps due to running on Windows? or just PEBKAC?) so ended up using a modified version of the plugin:
And in my
vite.config.ts
:Hopefully that helps if others run into this situation.