esbuild-plugin-cdn-imports
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

esbuild-plugin-cdn-imports

npm version npm downloads

✨ Intercepts imports and resolves them to a CDN URL - useful for places where the filesystem is not available, such as in the browser.

📦 Installation

npm install -D esbuild esbuild-plugin-cdn-imports

📚 Usage

Add this to your build file

import { build } from "esbuild";
import { CDNImports } from "esbuild-plugin-cdn-imports";

const yourConfig = {};

await build({
  ...yourConfig,
  plugins: [
    CDNImports({
      // Available cdns: "esm", "unpkg", "jsdelivr", "skypack"
      cdn: "esm",
      versions: {
        // The version of the package to use
        // If not specified, the latest version will be used
        "react": "17.0.2",
        "react-dom": "17.0.2"
      },
      // This will not be resolved to a CDN URL
      exclude: ["@prisma/client"]
    })
  ]
});

📄 License

Published under MIT License.

/esbuild-plugin-cdn-imports/

    Package Sidebar

    Install

    npm i esbuild-plugin-cdn-imports

    Weekly Downloads

    4

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    25.7 kB

    Total Files

    7

    Last publish

    Collaborators

    • luxass