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

0.1.2 • Public • Published

vite-plugin-cloudflare-redirect

Vite plugin to handle Cloudflare's _redirects file following https://developers.cloudflare.com/pages/platform/redirects/.

Usage

Create a _redirects file at /public (or following the publicDir config):

# /public/_redirects
/foo https://example.com 302
// vite.config.js
import { defineConfig } from 'vite'
import { cloudflareRedirect } from 'vite-plugin-cloudflare-redirect'

export default defineConfig({
  plugins: [
    cloudflareRedirect({
      redirectsFile: './custom/_redirects' // optional
    })
  ]
})

By default if no options are passed, the plugin would try to load from /public/_redirects (from publicDir config). If the file isn't found, no redirects will happen. Pass the redirectsFile option to specify a custom path.

Sponsors

Sponsors

License

MIT

Package Sidebar

Install

npm i vite-plugin-cloudflare-redirect

Weekly Downloads

4

Version

0.1.2

License

MIT

Unpacked Size

4.83 kB

Total Files

5

Last publish

Collaborators

  • bluwy