Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luxass/esbuild-cdn-imports
This plugin intercepts imports and resolves them to a CDN URL.
https://github.com/luxass/esbuild-cdn-imports
cdn cdn-imports esbuild esbuild-plugin
Last synced: about 1 month ago
JSON representation
This plugin intercepts imports and resolves them to a CDN URL.
- Host: GitHub
- URL: https://github.com/luxass/esbuild-cdn-imports
- Owner: luxass
- License: mit
- Created: 2023-04-01T09:18:57.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-14T02:03:55.000Z (about 1 month ago)
- Last Synced: 2024-08-14T03:46:50.405Z (about 1 month ago)
- Topics: cdn, cdn-imports, esbuild, esbuild-plugin
- Language: TypeScript
- Homepage:
- Size: 396 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# esbuild-plugin-cdn-imports
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]✨ Intercepts imports and resolves them to a CDN URL - useful for places where the filesystem is not available, such as in the browser.
## 📦 Installation
```sh
npm install -D esbuild esbuild-plugin-cdn-imports
```## 📚 Usage
Add this to your build file
```js
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](./LICENSE).
[npm-version-src]: https://img.shields.io/npm/v/esbuild-plugin-cdn-imports?style=flat&colorA=18181B&colorB=4169E1
[npm-version-href]: https://npmjs.com/package/esbuild-plugin-cdn-imports
[npm-downloads-src]: https://img.shields.io/npm/dm/esbuild-plugin-cdn-imports?style=flat&colorA=18181B&colorB=4169E1
[npm-downloads-href]: https://npmjs.com/package/esbuild-plugin-cdn-imports