vite-plugin-map-cdn
TypeScript icon, indicating that this package has built-in type declarations

0.1.9 • Public • Published

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.

NPM

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>

License

MIT

Package Sidebar

Install

npm i vite-plugin-map-cdn

Weekly Downloads

2

Version

0.1.9

License

MIT

Unpacked Size

6.19 kB

Total Files

7

Last publish

Collaborators

  • tophattedcoder