vite-plugin-url-redirect
v0.1.0
Published
Redirect a source url to another one.
Downloads
214
Readme
vite-plugin-url-redirect
Redirect a source url to another one.
Install
$> npm install vite-plugin-url-redirect
Usage
//vite.config.ts
import { redirect } from 'vite-plugin-url-redirect';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
// An example for redirect to a local server with absolute path.
redirect({
form: /\/basename\/.*\.(jpg|jpeg|png|gif)/,
to: (src: string) => `http://localhost:3000${src}`,
}),
],
});
Options
declare type From = RegExp | string;
declare type To = string | ((src: string) => string);
interface RedirectOptions {
/**
* The URL which should redirect
*/
from: From;
/**
* The URL which redirect to.
*/
to: To;
}