Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to integrate vue-leaflet via CDN? #369

Open
aimeos opened this issue Feb 3, 2024 · 2 comments
Open

How to integrate vue-leaflet via CDN? #369

aimeos opened this issue Feb 3, 2024 · 2 comments

Comments

@aimeos
Copy link

aimeos commented Feb 3, 2024

All provided examples use build tools for compilation but how to integrate Vue3 Leaflet components like the Vue2 components via CDN like described here:
https://vue2-leaflet.netlify.app/quickstart/#if-imported-by-cdn

@daufinsyd
Copy link

That would be awesome ! :)

@chaoliuchn
Copy link

you can use the vite-plugin-cdn-import plugin to solve this problem. This plugin allows your project to load dependencies from a CDN, which can enhance the loading speed and performance of your project.
To use this plugin, follow these steps:

  1. First, install the vite-plugin-cdn-import plugin:
    npm install vite-plugin-cdn-import --save-dev
  2. Then, import and configure the plugin in your vite.config.js file:
// vite.config.js
import cdn from 'vite-plugin-cdn-import'
export default {
    plugins: [
        cdn({
            prodUrl: '//unpkg.com/{name}@{version}/{path}',
            modules: [
               'vue',
                {
                    name: '@vue-leaflet/vue-leaflet',
                    var: 'globalThis["vue-leaflet"]',
                    path: 'dist/vue-leaflet.umd.js',
                },
            ],
        }),
    ],
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants