vite-cdn-uploader
v0.2.4
Published
A Vite plugin to upload built files to various CDN providers
Downloads
21
Readme
Vite CDN Uploader Plugin 🚀
The Vite CDN Uploader Plugin is a handy utility to automatically upload build files from Vite projects to various CDN providers. It currently supports Amazon S3 and Custom Providers.
Installation 💻
Install the plugin via npm or yarn:
npm install --save-dev vite-cdn-uploader
or
yarn add -D vite-cdn-uploader
Usage 🛠
First, import the plugin in your Vite configuration file:
import { cdnUploaderPlugin, providers } from "vite-cdn-uploader"
If your project does not have an .env
file yet:
touch .env
Then, add the following content to your .env
file:
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=
AWS_BUCKET=
Then, add the plugin to the plugins
array in your Vite configuration:
export default {
plugins: [
cdnUploaderPlugin({
provider: new providers.AwsS3Provider(),
}),
],
};
Custom Provider 🎛
Create a custom provider by defining a class with a config
method and an upload
method:
class CustomProvider {
config() {
// Provider Configs
return {};
}
async upload(file, filePath) {
// Upload Process
}
}
Vite Configuration 📝
Include your custom provider in your Vite configuration:
export default {
plugins: [
cdnUploaderPlugin({
provider: new CustomProvider(),
}),
],
};
License 📄
MIT