0.1.4 • Published 14 days ago

unplugin-esm-cdn v0.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days ago

unplugin-esm-cdn

NPM version

build plugin

Usage

esmCdn({
  sleep:1000, // Waiting for module collection, may have a higher value
  cdn:'npmmirror',
  modules:['vue','vue-router'],
})

Install

npm i unplugin-esm-cdn -d
// vite.config.ts
import esmCdn from 'unplugin-esm-cdn/vite'

export default defineConfig({
  plugins: [
    esmCdn({ /* options */ }),
  ],
})

Example: playground/

// rollup.config.js
import esmCdn from 'unplugin-esm-cdn/rollup'

export default {
  plugins: [
    esmCdn({ /* options */ }),
  ],
}

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-esm-cdn/webpack')({ /* options */ })
  ]
}

// nuxt.config.js
export default defineNuxtConfig({
  modules: [
    ['unplugin-esm-cdn/nuxt', { /* options */ }],
  ],
})

This module works for both Nuxt 2 and Nuxt Vite

// vue.config.js
module.exports = {
  configureWebpack: {
    plugins: [
      require('unplugin-esm-cdn/webpack')({ /* options */ }),
    ],
  },
}

// esbuild.config.js
import { build } from 'esbuild'
import esmCdn from 'unplugin-esm-cdn/esbuild'

build({
  plugins: [esmCdn()],
})