@openpolicy/vite 0.0.9 → 0.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +56 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,3 +1,57 @@
1
- # OpenPolicy Vite
1
+ # `@openpolicy/vite`
2
2
 
3
- This is the Vite package for the OpenPolicy project.
3
+ > Vite plugin for compiling [OpenPolicy](https://openpolicy.sh) policy documents at build time.
4
+
5
+ Compiles `definePrivacyPolicy()` and `defineTermsOfService()` configs to Markdown or HTML automatically — on every build and on save in dev mode.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ bun add -D @openpolicy/vite
11
+ bun add @openpolicy/sdk
12
+ # or: npm install --save-dev @openpolicy/vite @openpolicy/sdk
13
+ ```
14
+
15
+ ## Setup
16
+
17
+ ```ts
18
+ // vite.config.ts
19
+ import { defineConfig } from "vite";
20
+ import { openPolicy } from "@openpolicy/vite";
21
+
22
+ export default defineConfig({
23
+ plugins: [
24
+ openPolicy({
25
+ configs: ["privacy.config.ts", "terms.config.ts"],
26
+ formats: ["markdown"],
27
+ outDir: "public/policies",
28
+ }),
29
+ ],
30
+ });
31
+ ```
32
+
33
+ ## Options
34
+
35
+ | Option | Type | Default | Description |
36
+ |---|---|---|---|
37
+ | `configs` | `PolicyConfigEntry[]` | — | Policy configs to compile. Type is auto-detected from filename (`"terms"` → terms of service, otherwise privacy). Each entry is a path string or `{ config: string; type?: "privacy" \| "terms" }`. |
38
+ | `formats` | `OutputFormat[]` | `["markdown"]` | `"markdown"` or `"html"` |
39
+ | `outDir` | `string` | `"public/policies"` | Output directory, relative to the Vite root |
40
+
41
+ ## Scaffold
42
+
43
+ If a config file doesn't exist when Vite starts, the plugin creates a starter file with placeholder content — edit and save to generate your first policy.
44
+
45
+ ## Astro
46
+
47
+ For Astro projects, use [`@openpolicy/astro`](https://openpolicy.sh/docs/getting-started/astro) instead — it wraps this plugin and plugs into Astro's integration API.
48
+
49
+ ## Documentation
50
+
51
+ [openpolicy.sh/docs/getting-started/vite](https://openpolicy.sh/docs/getting-started/vite)
52
+
53
+ ## Links
54
+
55
+ - [GitHub](https://github.com/jamiedavenport/openpolicy)
56
+ - [openpolicy.sh](https://openpolicy.sh)
57
+ - [npm](https://www.npmjs.com/package/@openpolicy/vite)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpolicy/vite",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "type": "module",
5
5
  "description": "Vite plugin for compiling OpenPolicy privacy policy documents at build time",
6
6
  "license": "MIT",