# pages-vite-early-hints-plugin

> A vite plugin to generate the _headers file with early hints for Cloudflare Pages

Latest version **0.2.0** (published 2023-06-12) · ISC license · 0 weekly downloads

## Install

```sh
npm install pages-vite-early-hints-plugin
pnpm add pages-vite-early-hints-plugin
yarn add pages-vite-early-hints-plugin
bun add pages-vite-early-hints-plugin
```

## 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.2.0 |
| Published | 2023-06-12 |
| First published | 2023-06-06 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 16.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Donato Wolfisberg |
| Maintainers | sircremefresh |
| Keywords | cloudflare, pages, vite, early-hints |

## Links

- npm: https://www.npmjs.com/package/pages-vite-early-hints-plugin
- npm.io page: https://npm.io/package/pages-vite-early-hints-plugin

## 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.2.0 (latest) — 2023-06-12
- 0.2.1-0 (next) — 2023-06-12
- 0.1.17-3 — 2023-06-12
- 0.1.17-2 — 2023-06-12
- 0.1.17-1 — 2023-06-12
- 0.1.16 — 2023-06-11
- 0.1.15 — 2023-06-11
- 0.1.14 — 2023-06-11
- 0.1.13 — 2023-06-11
- 0.1.12 — 2023-06-11
- 0.1.11 — 2023-06-11
- 0.1.6 — 2023-06-11
- 0.1.1 — 2023-06-06

## README

<!--suppress ALL -->
<h1 align="center">Welcome to Pages Vite Early Hints Plugin 👋</h1>

[![Test](https://github.com/SirCremefresh/pages-vite-early-hints-plugin/actions/workflows/test.js.yaml/badge.svg)](https://github.com/SirCremefresh/pages-vite-early-hints-plugin/actions/workflows/test.js.yaml)
![npm](https://img.shields.io/npm/v/pages-vite-early-hints-plugin?style=flat-square)

> A vite plugin to generate the _headers file with early hints for Cloudflare Pages

## Install

```sh
npm install pages-vite-early-hints-plugin
```

## Usage

For a vite, react and typescript project you can use the following config:
In this case it will take the Editor.js chuck and add it as early hint for the path `/edit/*` and the index.css chuck
for the path `/*`.

```typescript
import {defineConfig} from "vite";
import react from "@vitejs/plugin-react-swc";
import tsconfigPaths from "vite-tsconfig-paths";
import {earlyHints} from "pages-vite-early-hints-plugin";

export default defineConfig({
    plugins: [
        tsconfigPaths(),
        react(),
        earlyHints({
            hints: [
                {
                    name: "Editor",
                    type: "js",
                    path: "/edit/*",
                },
                {
                    name: "index",
                    type: "css",
                    path: "/*",
                },
            ]
        }),
    ],
});
```

The Generated _headers file will be in the dist folder and look like this:

```text
/edit/*
  Link: </assets/Editor-6141d1aa.js>; rel=preload; as=script
/*
  Link: </assets/index-48eeb833.css>; rel=preload; as=style
```

## Features

Generate the _headers file with early hints for Cloudflare Pages with the correct hashes on vite build.

## API

```typescript
type earlyHints = (
    options: Options
) => Plugin;

type Options = {
    hints: { type: FileEnding; name: string; path: string }[];
};

type FileEnding = "css" | "js";
```

## Run tests

```sh
npm test
```

## Me

👤 **Donato Wolfisberg (donato@wolfibserg.dev) [@SirCremefresh](https://github.com/SirCremefresh)**

---
_Source: https://npm.io/package/pages-vite-early-hints-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
