# unplugin-cloudflare-headers

> Generates cloudflare compatible headers with _headers file

Latest version **0.3.3** (published 2023-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install unplugin-cloudflare-headers
pnpm add unplugin-cloudflare-headers
yarn add unplugin-cloudflare-headers
bun add unplugin-cloudflare-headers
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.3 |
| Published | 2023-07-20 |
| First published | 2022-11-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 27.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Bogdan Kostyuk |
| Maintainers | logotip4ik_ |
| Keywords | unplugin, vite, webpack, rollup, transform, cloudflare, headers |

## Links

- npm: https://www.npmjs.com/package/unplugin-cloudflare-headers
- Repository: https://github.com/logotip4ik/unplugin-cloudflare-headers
- Homepage: https://github.com/logotip4ik/unplugin-cloudflare-headers#readme
- Issues: https://github.com/logotip4ik/unplugin-cloudflare-headers/issues
- npm.io page: https://npm.io/package/unplugin-cloudflare-headers

## Dependencies (1)

- [unplugin](https://npm.io/package/unplugin.md) ^1.0.1

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.3.3 (latest) — 2023-07-20
- 0.3.2 — 2023-07-20
- 0.3.1 — 2022-12-15
- 0.3.0 — 2022-12-15
- 0.2.0 — 2022-12-14
- 0.1.2 — 2022-11-03
- 0.1.1 — 2022-11-03

## README

# unplugin-cloudflare-headers

[![NPM version](https://img.shields.io/npm/v/unplugin-cloudflare-headers?color=a1b858&label=)](https://www.npmjs.com/package/unplugin-cloudflare-headers)

## Install

```bash
npm i unplugin-cloudflare-headers
```


## Usage

Vite

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

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

<details>
<summary>Rollup</summary><br>

```ts
// rollup.config.js
import CloudflareHeaders from 'unplugin-cloudflare-headers/rollup'

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

<br></details>


<details>
<summary>Webpack</summary><br>

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

<br></details>

<details>
<summary>esbuild</summary><br>

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

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

<br></details>


## 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:
```js
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:

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

More on `_headers` file in [cloudflare docs](https://developers.cloudflare.com/pages/platform/headers)

License [MIT](./LICENSE)

---
_Source: https://npm.io/package/unplugin-cloudflare-headers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
