A Vite plugin to replace all dependencies with URL imports to the specified origin. This plugin allows you to load dependencies from different origins or CDNs by modifying the import statements in your code.
You can install the plugin using npm:
npm install vite-url-import
or yarn:
yarn add vite-url-import
or pnpm:
pnpm add vite-url-import
The UrlImport function accepts an options object with the following properties:
- hostname: (optional): Specifies the origin or CDN to fetch the dependencies from. this property is a string and defaults to
esm.sh
.
// vite.config.js
import UrlImport from 'vite-url-import';
export default {
plugins: [
UrlImport()
]
}
If you look in your network tab, you will see that all your dependencies are now being fetched from the specified origin instead of your local machine.
This plugin is licensed under the MIT License.