An example that shows how to create a custom Vite plugin
vite-plugin-corp-headers is a plugin for Vite.js that is an example plugin showing how to customize the Vite build system. This plugin is designed to seamlessly integrate with Vite.js, leveraging its fast and efficient development server.
The example
directory is a vanilla Vite project generated with the following options:
npx create-vite@latest
- project name: example
- framework: Vanilla
- variant: Typescript
The vite.config.ts
configuration file shows how to use a Vite plugin:
import pluginCORPHeaders from "../src/index";
export default {
plugins: [
pluginCORPHeaders({
// Configuration options
}),
],
};
- Build the plugin
npm run build
- Start the Vite development server:
cd example
npm run dev
- Your development server will be available at
http://localhost:5173
by default.
The plugin supports the following configuration options:
coep
: Default "require-corp". Options: ["unsafe-none", "require-corp"]coop
: Default "same-origin". Options: ["unsafe-none", "same-origin-allow-popups", "same-origin"] Please refer to the CORP documentation for more details on these configuration options.
This plugin is licensed under the Apache 2.0.