This package has been deprecated

Author message:

This package does not conform to the vite plugin naming conventions and has been moved to @ikasoba000/vite-plugin-cdn

@ikasoba000/vite-cdn
TypeScript icon, indicating that this package has built-in type declarations

0.2.3 • Public • Published

vite-plugin-cdn📦

Plugin to use javascript package cdn in vite.

import { defineConfig } from "vite";
import cdn from "@ikasoba000/vite-plugin-cdn";

export default defineConfig({
  plugins: [
    cdn()
  ],
});

about

vite-cdn refers to esm.sh by default, but it can also refer to cdn such as skypack.

export default defineConfig({
  plugins: [
    cdn({
      // :name, :version, and :path are specifiers for substitution.
      pattern: "https://cdn.skypack.dev/:name@:version/:path"
    })
  ],
});

A function can also be specified for a pattern.

export default defineConfig({
  plugins: [
    cdn({
      pattern(name: string, version: string, path?: string) {
        return name == "react"
          ? `https://esm.sh/preact@${version}/${path ?? ""}`
          : `https://cdn.skypack.dev/${name}@${version}/${path ?? ""}`;
      }
    })
  ],
});

You can explicitly select or exclude packages to be loaded from cdn.

export default defineConfig({
  plugins: [
    cdn({
      // By default, all packages are loaded from cdn.
      packages: [ <package-name>, ... ]
    })
  ],
});

// or

export default defineConfig({
  plugins: [
    cdn({
      // Packages specified here are not loaded from cdn,
      // but are bundled by vite in many cases.
      excludes: [ <package-name>, ... ]
    })
  ],
});

Readme

Keywords

none

Package Sidebar

Install

npm i @ikasoba000/vite-cdn

Weekly Downloads

0

Version

0.2.3

License

MIT

Unpacked Size

5.11 kB

Total Files

6

Last publish

Collaborators

  • ikasoba000