vite-plugin-map-cdn
v0.1.9
Published
Use dependencies from CDNs using import-maps in vite
Downloads
19
Maintainers
Readme
vite-plugin-cdn-map
Use native browser import-maps in vite for CDN resolution. What's import-maps
This plugin by default tries to resolve all dependencies as CDN libraries.
Usage
Simply add CDN plugin in vite.config
// vite.config.ts
const { defineConfig } = require('vite')
import cdn from 'vite-plugin-map-cdn'
export default defineConfig({
plugins: [
cdn({cdn: "unpkg.sh"})
],
})
Then your module will import from cdn instead of vite pre-bundling it.
Because this solution uses native import-maps, itt also allow you to use module in runtime:
<!-- index.html -->
<script type="module">
import _, { isNaN } from 'lodash'
console.log(_.isNaN(NaN)) // true
console.log(isNaN(NaN)) // true
</script>