vite-plugin-url-redirect
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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;
}

License

MIT

/vite-plugin-url-redirect/

    Package Sidebar

    Install

    npm i vite-plugin-url-redirect

    Weekly Downloads

    14

    Version

    0.1.0

    License

    ISC

    Unpacked Size

    57.7 kB

    Total Files

    16

    Last publish

    Collaborators

    • fanhaoyuan