0.3.3 • Published 10 months ago

unplugin-cloudflare-headers v0.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

unplugin-cloudflare-headers

NPM version

Install

npm i unplugin-cloudflare-headers

Usage

Vite

// vite.config.ts
import CloudflareHeaders from 'unplugin-cloudflare-headers/vite'

export default defineConfig({
  plugins: [
    CloudflareHeaders({ /* options */ }),
  ],
})
// rollup.config.js
import CloudflareHeaders from 'unplugin-cloudflare-headers/rollup'

export default {
  plugins: [
    CloudflareHeaders({ /* options */ }),
  ],
}

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [
    require('unplugin-cloudflare-headers/webpack')({ /* options */ })
  ]
}

// esbuild.config.js
import { build } from 'esbuild'
import CloudflareHeaders from 'unplugin-cloudflare-headers/esbuild'

build({
  plugins: [CloudflareHeaders()],
})

Options

Top level keys of the options are route definitions. Each route should have an array of headers. Header is simple object, where key is header name and value (string or false) is header value. Let's see example.

This options:

const options = {
  '/*': [{ 'x-testing': 'hello 🌐' }],
  '/admin': [{ 'x-testing': false }]
  // use `false` as header value to detach header from specific route
}

will result into this _headers file:

/*
	x-testing: hello 🌐
/admin
	! x-testing

More on _headers file in cloudflare docs

License MIT

0.3.2

10 months ago

0.3.3

10 months ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.2

2 years ago

0.1.1

2 years ago