vite-plugin-vercel 0.3.0 → 0.3.2
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.
- package/README.md +31 -1
- package/dist/index.d.cts +648 -0
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -41,12 +41,42 @@ export default defineConfig({
|
|
|
41
41
|
|
|
42
42
|
[vite-plugin-ssr](https://vite-plugin-ssr.com/) is supported through [@vite-plugin-vercel/vike](/packages/vike-integration/README.md) plugin.
|
|
43
43
|
|
|
44
|
-
You only need to install `@vite-plugin-vercel/vike`, the config stays the same as above.
|
|
44
|
+
You only need to install `@vite-plugin-vercel/vike`, the Vite config stays the same as above.
|
|
45
45
|
|
|
46
46
|
> [!IMPORTANT]
|
|
47
47
|
> `@vite-plugin-vercel/vike` supersedes the old `@magne4000/vite-plugin-vercel-ssr` package.
|
|
48
48
|
> As such, you should remove `@magne4000/vite-plugin-vercel-ssr` from your package.json and vite config file.
|
|
49
49
|
|
|
50
|
+
### vite-plugin-ssr V1 design
|
|
51
|
+
|
|
52
|
+
`vite-plugin-vercel` fully supports [vite-plugin-ssr V1 design](https://vite-plugin-ssr.com/migration/v1-design),
|
|
53
|
+
and thus you can leverage [config files](https://vite-plugin-ssr.com/config) to customize ISR configuration:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
// /pages/product/+config.h.ts
|
|
57
|
+
|
|
58
|
+
import Page from './Page';
|
|
59
|
+
import type { Config } from 'vite-plugin-ssr/types';
|
|
60
|
+
|
|
61
|
+
// Customize ISR config for this page
|
|
62
|
+
export default {
|
|
63
|
+
isr: { expiration: 15 },
|
|
64
|
+
} satisfies Config;
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
You will also need to extend the [renderer config](https://vite-plugin-ssr.com/config#renderer) so that `vite-plugin-ssr` is aware of the new parameter:
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
// /renderer/+config.h.ts
|
|
71
|
+
|
|
72
|
+
import config from '@vite-plugin-vercel/vike/config';
|
|
73
|
+
import type { Config } from 'vite-plugin-ssr/types';
|
|
74
|
+
|
|
75
|
+
export default {
|
|
76
|
+
extends: config,
|
|
77
|
+
} satisfies Config;
|
|
78
|
+
```
|
|
79
|
+
|
|
50
80
|
## Advanced usage
|
|
51
81
|
|
|
52
82
|
```ts
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,648 @@
|
|
|
1
|
+
import { ResolvedConfig, PluginOption } from 'vite';
|
|
2
|
+
import { StdinOptions, BuildOptions } from 'esbuild';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { Rewrite, Redirect } from '@vercel/routing-utils';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Schema definition for `.vercel/output/config.json`
|
|
8
|
+
* @see {@link https://vercel.com/docs/build-output-api/v3#build-output-configuration}
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
declare const vercelOutputConfigSchema: z.ZodObject<{
|
|
12
|
+
version: z.ZodLiteral<3>;
|
|
13
|
+
routes: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
14
|
+
src: z.ZodString;
|
|
15
|
+
dest: z.ZodOptional<z.ZodString>;
|
|
16
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
17
|
+
methods: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
18
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
continue: z.ZodOptional<z.ZodBoolean>;
|
|
20
|
+
check: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
missing: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
22
|
+
type: z.ZodLiteral<"host">;
|
|
23
|
+
value: z.ZodString;
|
|
24
|
+
}, "strict", z.ZodTypeAny, {
|
|
25
|
+
value: string;
|
|
26
|
+
type: "host";
|
|
27
|
+
}, {
|
|
28
|
+
value: string;
|
|
29
|
+
type: "host";
|
|
30
|
+
}>, z.ZodObject<{
|
|
31
|
+
type: z.ZodLiteral<"header">;
|
|
32
|
+
key: z.ZodString;
|
|
33
|
+
value: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, "strict", z.ZodTypeAny, {
|
|
35
|
+
type: "header";
|
|
36
|
+
key: string;
|
|
37
|
+
value?: string | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
type: "header";
|
|
40
|
+
key: string;
|
|
41
|
+
value?: string | undefined;
|
|
42
|
+
}>, z.ZodObject<{
|
|
43
|
+
type: z.ZodLiteral<"cookie">;
|
|
44
|
+
key: z.ZodString;
|
|
45
|
+
value: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, "strict", z.ZodTypeAny, {
|
|
47
|
+
type: "cookie";
|
|
48
|
+
key: string;
|
|
49
|
+
value?: string | undefined;
|
|
50
|
+
}, {
|
|
51
|
+
type: "cookie";
|
|
52
|
+
key: string;
|
|
53
|
+
value?: string | undefined;
|
|
54
|
+
}>, z.ZodObject<{
|
|
55
|
+
type: z.ZodLiteral<"query">;
|
|
56
|
+
key: z.ZodString;
|
|
57
|
+
value: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, "strict", z.ZodTypeAny, {
|
|
59
|
+
type: "query";
|
|
60
|
+
key: string;
|
|
61
|
+
value?: string | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
type: "query";
|
|
64
|
+
key: string;
|
|
65
|
+
value?: string | undefined;
|
|
66
|
+
}>]>, "many">>;
|
|
67
|
+
has: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodObject<{
|
|
68
|
+
type: z.ZodLiteral<"host">;
|
|
69
|
+
value: z.ZodString;
|
|
70
|
+
}, "strict", z.ZodTypeAny, {
|
|
71
|
+
value: string;
|
|
72
|
+
type: "host";
|
|
73
|
+
}, {
|
|
74
|
+
value: string;
|
|
75
|
+
type: "host";
|
|
76
|
+
}>, z.ZodObject<{
|
|
77
|
+
type: z.ZodLiteral<"header">;
|
|
78
|
+
key: z.ZodString;
|
|
79
|
+
value: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, "strict", z.ZodTypeAny, {
|
|
81
|
+
type: "header";
|
|
82
|
+
key: string;
|
|
83
|
+
value?: string | undefined;
|
|
84
|
+
}, {
|
|
85
|
+
type: "header";
|
|
86
|
+
key: string;
|
|
87
|
+
value?: string | undefined;
|
|
88
|
+
}>, z.ZodObject<{
|
|
89
|
+
type: z.ZodLiteral<"cookie">;
|
|
90
|
+
key: z.ZodString;
|
|
91
|
+
value: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, "strict", z.ZodTypeAny, {
|
|
93
|
+
type: "cookie";
|
|
94
|
+
key: string;
|
|
95
|
+
value?: string | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
type: "cookie";
|
|
98
|
+
key: string;
|
|
99
|
+
value?: string | undefined;
|
|
100
|
+
}>, z.ZodObject<{
|
|
101
|
+
type: z.ZodLiteral<"query">;
|
|
102
|
+
key: z.ZodString;
|
|
103
|
+
value: z.ZodOptional<z.ZodString>;
|
|
104
|
+
}, "strict", z.ZodTypeAny, {
|
|
105
|
+
type: "query";
|
|
106
|
+
key: string;
|
|
107
|
+
value?: string | undefined;
|
|
108
|
+
}, {
|
|
109
|
+
type: "query";
|
|
110
|
+
key: string;
|
|
111
|
+
value?: string | undefined;
|
|
112
|
+
}>]>, "many">>;
|
|
113
|
+
locale: z.ZodOptional<z.ZodObject<{
|
|
114
|
+
redirect: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
115
|
+
cookie: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, "strict", z.ZodTypeAny, {
|
|
117
|
+
redirect?: Record<string, string> | undefined;
|
|
118
|
+
cookie?: string | undefined;
|
|
119
|
+
}, {
|
|
120
|
+
redirect?: Record<string, string> | undefined;
|
|
121
|
+
cookie?: string | undefined;
|
|
122
|
+
}>>;
|
|
123
|
+
middlewarePath: z.ZodOptional<z.ZodString>;
|
|
124
|
+
}, "strict", z.ZodTypeAny, {
|
|
125
|
+
src: string;
|
|
126
|
+
dest?: string | undefined;
|
|
127
|
+
headers?: Record<string, string> | undefined;
|
|
128
|
+
methods?: string[] | undefined;
|
|
129
|
+
status?: number | undefined;
|
|
130
|
+
continue?: boolean | undefined;
|
|
131
|
+
check?: boolean | undefined;
|
|
132
|
+
missing?: ({
|
|
133
|
+
value: string;
|
|
134
|
+
type: "host";
|
|
135
|
+
} | {
|
|
136
|
+
type: "header";
|
|
137
|
+
key: string;
|
|
138
|
+
value?: string | undefined;
|
|
139
|
+
} | {
|
|
140
|
+
type: "cookie";
|
|
141
|
+
key: string;
|
|
142
|
+
value?: string | undefined;
|
|
143
|
+
} | {
|
|
144
|
+
type: "query";
|
|
145
|
+
key: string;
|
|
146
|
+
value?: string | undefined;
|
|
147
|
+
})[] | undefined;
|
|
148
|
+
has?: ({
|
|
149
|
+
value: string;
|
|
150
|
+
type: "host";
|
|
151
|
+
} | {
|
|
152
|
+
type: "header";
|
|
153
|
+
key: string;
|
|
154
|
+
value?: string | undefined;
|
|
155
|
+
} | {
|
|
156
|
+
type: "cookie";
|
|
157
|
+
key: string;
|
|
158
|
+
value?: string | undefined;
|
|
159
|
+
} | {
|
|
160
|
+
type: "query";
|
|
161
|
+
key: string;
|
|
162
|
+
value?: string | undefined;
|
|
163
|
+
})[] | undefined;
|
|
164
|
+
locale?: {
|
|
165
|
+
redirect?: Record<string, string> | undefined;
|
|
166
|
+
cookie?: string | undefined;
|
|
167
|
+
} | undefined;
|
|
168
|
+
middlewarePath?: string | undefined;
|
|
169
|
+
}, {
|
|
170
|
+
src: string;
|
|
171
|
+
dest?: string | undefined;
|
|
172
|
+
headers?: Record<string, string> | undefined;
|
|
173
|
+
methods?: string[] | undefined;
|
|
174
|
+
status?: number | undefined;
|
|
175
|
+
continue?: boolean | undefined;
|
|
176
|
+
check?: boolean | undefined;
|
|
177
|
+
missing?: ({
|
|
178
|
+
value: string;
|
|
179
|
+
type: "host";
|
|
180
|
+
} | {
|
|
181
|
+
type: "header";
|
|
182
|
+
key: string;
|
|
183
|
+
value?: string | undefined;
|
|
184
|
+
} | {
|
|
185
|
+
type: "cookie";
|
|
186
|
+
key: string;
|
|
187
|
+
value?: string | undefined;
|
|
188
|
+
} | {
|
|
189
|
+
type: "query";
|
|
190
|
+
key: string;
|
|
191
|
+
value?: string | undefined;
|
|
192
|
+
})[] | undefined;
|
|
193
|
+
has?: ({
|
|
194
|
+
value: string;
|
|
195
|
+
type: "host";
|
|
196
|
+
} | {
|
|
197
|
+
type: "header";
|
|
198
|
+
key: string;
|
|
199
|
+
value?: string | undefined;
|
|
200
|
+
} | {
|
|
201
|
+
type: "cookie";
|
|
202
|
+
key: string;
|
|
203
|
+
value?: string | undefined;
|
|
204
|
+
} | {
|
|
205
|
+
type: "query";
|
|
206
|
+
key: string;
|
|
207
|
+
value?: string | undefined;
|
|
208
|
+
})[] | undefined;
|
|
209
|
+
locale?: {
|
|
210
|
+
redirect?: Record<string, string> | undefined;
|
|
211
|
+
cookie?: string | undefined;
|
|
212
|
+
} | undefined;
|
|
213
|
+
middlewarePath?: string | undefined;
|
|
214
|
+
}>, z.ZodObject<{
|
|
215
|
+
handle: z.ZodUnion<[z.ZodLiteral<"rewrite">, z.ZodLiteral<"filesystem">, z.ZodLiteral<"resource">, z.ZodLiteral<"miss">, z.ZodLiteral<"hit">, z.ZodLiteral<"error">]>;
|
|
216
|
+
src: z.ZodOptional<z.ZodString>;
|
|
217
|
+
dest: z.ZodOptional<z.ZodString>;
|
|
218
|
+
status: z.ZodOptional<z.ZodNumber>;
|
|
219
|
+
}, "strict", z.ZodTypeAny, {
|
|
220
|
+
handle: "error" | "rewrite" | "filesystem" | "resource" | "miss" | "hit";
|
|
221
|
+
src?: string | undefined;
|
|
222
|
+
dest?: string | undefined;
|
|
223
|
+
status?: number | undefined;
|
|
224
|
+
}, {
|
|
225
|
+
handle: "error" | "rewrite" | "filesystem" | "resource" | "miss" | "hit";
|
|
226
|
+
src?: string | undefined;
|
|
227
|
+
dest?: string | undefined;
|
|
228
|
+
status?: number | undefined;
|
|
229
|
+
}>]>, "many">>;
|
|
230
|
+
images: z.ZodOptional<z.ZodObject<{
|
|
231
|
+
sizes: z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>;
|
|
232
|
+
domains: z.ZodOptional<z.ZodArray<z.ZodString, "atleastone">>;
|
|
233
|
+
minimumCacheTTL: z.ZodOptional<z.ZodNumber>;
|
|
234
|
+
formats: z.ZodOptional<z.ZodArray<z.ZodUnion<[z.ZodLiteral<"image/avif">, z.ZodLiteral<"image/webp">]>, "atleastone">>;
|
|
235
|
+
dangerouslyAllowSVG: z.ZodOptional<z.ZodBoolean>;
|
|
236
|
+
contentSecurityPolicy: z.ZodOptional<z.ZodString>;
|
|
237
|
+
}, "strict", z.ZodTypeAny, {
|
|
238
|
+
sizes: [number, number];
|
|
239
|
+
domains?: [string, ...string[]] | undefined;
|
|
240
|
+
minimumCacheTTL?: number | undefined;
|
|
241
|
+
formats?: ["image/avif" | "image/webp", ...("image/avif" | "image/webp")[]] | undefined;
|
|
242
|
+
dangerouslyAllowSVG?: boolean | undefined;
|
|
243
|
+
contentSecurityPolicy?: string | undefined;
|
|
244
|
+
}, {
|
|
245
|
+
sizes: [number, number];
|
|
246
|
+
domains?: [string, ...string[]] | undefined;
|
|
247
|
+
minimumCacheTTL?: number | undefined;
|
|
248
|
+
formats?: ["image/avif" | "image/webp", ...("image/avif" | "image/webp")[]] | undefined;
|
|
249
|
+
dangerouslyAllowSVG?: boolean | undefined;
|
|
250
|
+
contentSecurityPolicy?: string | undefined;
|
|
251
|
+
}>>;
|
|
252
|
+
wildcard: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
253
|
+
domain: z.ZodString;
|
|
254
|
+
value: z.ZodString;
|
|
255
|
+
}, "strict", z.ZodTypeAny, {
|
|
256
|
+
value: string;
|
|
257
|
+
domain: string;
|
|
258
|
+
}, {
|
|
259
|
+
value: string;
|
|
260
|
+
domain: string;
|
|
261
|
+
}>, "many">>;
|
|
262
|
+
overrides: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
263
|
+
path: z.ZodOptional<z.ZodString>;
|
|
264
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
265
|
+
}, "strict", z.ZodTypeAny, {
|
|
266
|
+
path?: string | undefined;
|
|
267
|
+
contentType?: string | undefined;
|
|
268
|
+
}, {
|
|
269
|
+
path?: string | undefined;
|
|
270
|
+
contentType?: string | undefined;
|
|
271
|
+
}>>>;
|
|
272
|
+
cache: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
273
|
+
}, "strict", z.ZodTypeAny, {
|
|
274
|
+
version: 3;
|
|
275
|
+
routes?: ({
|
|
276
|
+
src: string;
|
|
277
|
+
dest?: string | undefined;
|
|
278
|
+
headers?: Record<string, string> | undefined;
|
|
279
|
+
methods?: string[] | undefined;
|
|
280
|
+
status?: number | undefined;
|
|
281
|
+
continue?: boolean | undefined;
|
|
282
|
+
check?: boolean | undefined;
|
|
283
|
+
missing?: ({
|
|
284
|
+
value: string;
|
|
285
|
+
type: "host";
|
|
286
|
+
} | {
|
|
287
|
+
type: "header";
|
|
288
|
+
key: string;
|
|
289
|
+
value?: string | undefined;
|
|
290
|
+
} | {
|
|
291
|
+
type: "cookie";
|
|
292
|
+
key: string;
|
|
293
|
+
value?: string | undefined;
|
|
294
|
+
} | {
|
|
295
|
+
type: "query";
|
|
296
|
+
key: string;
|
|
297
|
+
value?: string | undefined;
|
|
298
|
+
})[] | undefined;
|
|
299
|
+
has?: ({
|
|
300
|
+
value: string;
|
|
301
|
+
type: "host";
|
|
302
|
+
} | {
|
|
303
|
+
type: "header";
|
|
304
|
+
key: string;
|
|
305
|
+
value?: string | undefined;
|
|
306
|
+
} | {
|
|
307
|
+
type: "cookie";
|
|
308
|
+
key: string;
|
|
309
|
+
value?: string | undefined;
|
|
310
|
+
} | {
|
|
311
|
+
type: "query";
|
|
312
|
+
key: string;
|
|
313
|
+
value?: string | undefined;
|
|
314
|
+
})[] | undefined;
|
|
315
|
+
locale?: {
|
|
316
|
+
redirect?: Record<string, string> | undefined;
|
|
317
|
+
cookie?: string | undefined;
|
|
318
|
+
} | undefined;
|
|
319
|
+
middlewarePath?: string | undefined;
|
|
320
|
+
} | {
|
|
321
|
+
handle: "error" | "rewrite" | "filesystem" | "resource" | "miss" | "hit";
|
|
322
|
+
src?: string | undefined;
|
|
323
|
+
dest?: string | undefined;
|
|
324
|
+
status?: number | undefined;
|
|
325
|
+
})[] | undefined;
|
|
326
|
+
images?: {
|
|
327
|
+
sizes: [number, number];
|
|
328
|
+
domains?: [string, ...string[]] | undefined;
|
|
329
|
+
minimumCacheTTL?: number | undefined;
|
|
330
|
+
formats?: ["image/avif" | "image/webp", ...("image/avif" | "image/webp")[]] | undefined;
|
|
331
|
+
dangerouslyAllowSVG?: boolean | undefined;
|
|
332
|
+
contentSecurityPolicy?: string | undefined;
|
|
333
|
+
} | undefined;
|
|
334
|
+
wildcard?: {
|
|
335
|
+
value: string;
|
|
336
|
+
domain: string;
|
|
337
|
+
}[] | undefined;
|
|
338
|
+
overrides?: Record<string, {
|
|
339
|
+
path?: string | undefined;
|
|
340
|
+
contentType?: string | undefined;
|
|
341
|
+
}> | undefined;
|
|
342
|
+
cache?: string[] | undefined;
|
|
343
|
+
}, {
|
|
344
|
+
version: 3;
|
|
345
|
+
routes?: ({
|
|
346
|
+
src: string;
|
|
347
|
+
dest?: string | undefined;
|
|
348
|
+
headers?: Record<string, string> | undefined;
|
|
349
|
+
methods?: string[] | undefined;
|
|
350
|
+
status?: number | undefined;
|
|
351
|
+
continue?: boolean | undefined;
|
|
352
|
+
check?: boolean | undefined;
|
|
353
|
+
missing?: ({
|
|
354
|
+
value: string;
|
|
355
|
+
type: "host";
|
|
356
|
+
} | {
|
|
357
|
+
type: "header";
|
|
358
|
+
key: string;
|
|
359
|
+
value?: string | undefined;
|
|
360
|
+
} | {
|
|
361
|
+
type: "cookie";
|
|
362
|
+
key: string;
|
|
363
|
+
value?: string | undefined;
|
|
364
|
+
} | {
|
|
365
|
+
type: "query";
|
|
366
|
+
key: string;
|
|
367
|
+
value?: string | undefined;
|
|
368
|
+
})[] | undefined;
|
|
369
|
+
has?: ({
|
|
370
|
+
value: string;
|
|
371
|
+
type: "host";
|
|
372
|
+
} | {
|
|
373
|
+
type: "header";
|
|
374
|
+
key: string;
|
|
375
|
+
value?: string | undefined;
|
|
376
|
+
} | {
|
|
377
|
+
type: "cookie";
|
|
378
|
+
key: string;
|
|
379
|
+
value?: string | undefined;
|
|
380
|
+
} | {
|
|
381
|
+
type: "query";
|
|
382
|
+
key: string;
|
|
383
|
+
value?: string | undefined;
|
|
384
|
+
})[] | undefined;
|
|
385
|
+
locale?: {
|
|
386
|
+
redirect?: Record<string, string> | undefined;
|
|
387
|
+
cookie?: string | undefined;
|
|
388
|
+
} | undefined;
|
|
389
|
+
middlewarePath?: string | undefined;
|
|
390
|
+
} | {
|
|
391
|
+
handle: "error" | "rewrite" | "filesystem" | "resource" | "miss" | "hit";
|
|
392
|
+
src?: string | undefined;
|
|
393
|
+
dest?: string | undefined;
|
|
394
|
+
status?: number | undefined;
|
|
395
|
+
})[] | undefined;
|
|
396
|
+
images?: {
|
|
397
|
+
sizes: [number, number];
|
|
398
|
+
domains?: [string, ...string[]] | undefined;
|
|
399
|
+
minimumCacheTTL?: number | undefined;
|
|
400
|
+
formats?: ["image/avif" | "image/webp", ...("image/avif" | "image/webp")[]] | undefined;
|
|
401
|
+
dangerouslyAllowSVG?: boolean | undefined;
|
|
402
|
+
contentSecurityPolicy?: string | undefined;
|
|
403
|
+
} | undefined;
|
|
404
|
+
wildcard?: {
|
|
405
|
+
value: string;
|
|
406
|
+
domain: string;
|
|
407
|
+
}[] | undefined;
|
|
408
|
+
overrides?: Record<string, {
|
|
409
|
+
path?: string | undefined;
|
|
410
|
+
contentType?: string | undefined;
|
|
411
|
+
}> | undefined;
|
|
412
|
+
cache?: string[] | undefined;
|
|
413
|
+
}>;
|
|
414
|
+
type VercelOutputConfig = z.infer<typeof vercelOutputConfigSchema>;
|
|
415
|
+
|
|
416
|
+
/**
|
|
417
|
+
* Schema definition for `.vercel/output/config.json`
|
|
418
|
+
* @see {@link https://vercel.com/docs/build-output-api/v3#build-output-configuration}
|
|
419
|
+
*/
|
|
420
|
+
|
|
421
|
+
declare const vercelOutputVcConfigSchema: z.ZodUnion<[z.ZodObject<{
|
|
422
|
+
runtime: z.ZodLiteral<"edge">;
|
|
423
|
+
entrypoint: z.ZodString;
|
|
424
|
+
envVarsInUse: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
425
|
+
}, "strict", z.ZodTypeAny, {
|
|
426
|
+
runtime: "edge";
|
|
427
|
+
entrypoint: string;
|
|
428
|
+
envVarsInUse?: string[] | undefined;
|
|
429
|
+
}, {
|
|
430
|
+
runtime: "edge";
|
|
431
|
+
entrypoint: string;
|
|
432
|
+
envVarsInUse?: string[] | undefined;
|
|
433
|
+
}>, z.ZodObject<{
|
|
434
|
+
runtime: z.ZodString;
|
|
435
|
+
handler: z.ZodString;
|
|
436
|
+
memory: z.ZodOptional<z.ZodNumber>;
|
|
437
|
+
maxDuration: z.ZodOptional<z.ZodNumber>;
|
|
438
|
+
environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
439
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
440
|
+
}, "strict", z.ZodTypeAny, {
|
|
441
|
+
runtime: string;
|
|
442
|
+
handler: string;
|
|
443
|
+
memory?: number | undefined;
|
|
444
|
+
maxDuration?: number | undefined;
|
|
445
|
+
environment?: Record<string, string> | undefined;
|
|
446
|
+
regions?: string[] | undefined;
|
|
447
|
+
}, {
|
|
448
|
+
runtime: string;
|
|
449
|
+
handler: string;
|
|
450
|
+
memory?: number | undefined;
|
|
451
|
+
maxDuration?: number | undefined;
|
|
452
|
+
environment?: Record<string, string> | undefined;
|
|
453
|
+
regions?: string[] | undefined;
|
|
454
|
+
}>, z.ZodObject<{
|
|
455
|
+
runtime: z.ZodString;
|
|
456
|
+
handler: z.ZodString;
|
|
457
|
+
memory: z.ZodOptional<z.ZodNumber>;
|
|
458
|
+
maxDuration: z.ZodOptional<z.ZodNumber>;
|
|
459
|
+
environment: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
460
|
+
regions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
461
|
+
launcherType: z.ZodLiteral<"Nodejs">;
|
|
462
|
+
shouldAddHelpers: z.ZodOptional<z.ZodBoolean>;
|
|
463
|
+
shouldAddSourcemapSupport: z.ZodOptional<z.ZodBoolean>;
|
|
464
|
+
awsLambdaHandler: z.ZodOptional<z.ZodString>;
|
|
465
|
+
}, "strict", z.ZodTypeAny, {
|
|
466
|
+
runtime: string;
|
|
467
|
+
handler: string;
|
|
468
|
+
launcherType: "Nodejs";
|
|
469
|
+
memory?: number | undefined;
|
|
470
|
+
maxDuration?: number | undefined;
|
|
471
|
+
environment?: Record<string, string> | undefined;
|
|
472
|
+
regions?: string[] | undefined;
|
|
473
|
+
shouldAddHelpers?: boolean | undefined;
|
|
474
|
+
shouldAddSourcemapSupport?: boolean | undefined;
|
|
475
|
+
awsLambdaHandler?: string | undefined;
|
|
476
|
+
}, {
|
|
477
|
+
runtime: string;
|
|
478
|
+
handler: string;
|
|
479
|
+
launcherType: "Nodejs";
|
|
480
|
+
memory?: number | undefined;
|
|
481
|
+
maxDuration?: number | undefined;
|
|
482
|
+
environment?: Record<string, string> | undefined;
|
|
483
|
+
regions?: string[] | undefined;
|
|
484
|
+
shouldAddHelpers?: boolean | undefined;
|
|
485
|
+
shouldAddSourcemapSupport?: boolean | undefined;
|
|
486
|
+
awsLambdaHandler?: string | undefined;
|
|
487
|
+
}>]>;
|
|
488
|
+
type VercelOutputVcConfig = z.infer<typeof vercelOutputVcConfigSchema>;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Schema definition for `.vercel/output/config.json`
|
|
492
|
+
* @see {@link https://vercel.com/docs/build-output-api/v3#build-output-configuration}
|
|
493
|
+
*/
|
|
494
|
+
|
|
495
|
+
declare const vercelOutputPrerenderConfigSchema: z.ZodObject<{
|
|
496
|
+
expiration: z.ZodUnion<[z.ZodNumber, z.ZodLiteral<false>]>;
|
|
497
|
+
group: z.ZodOptional<z.ZodNumber>;
|
|
498
|
+
bypassToken: z.ZodOptional<z.ZodString>;
|
|
499
|
+
fallback: z.ZodOptional<z.ZodString>;
|
|
500
|
+
allowQuery: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
501
|
+
}, "strict", z.ZodTypeAny, {
|
|
502
|
+
expiration: number | false;
|
|
503
|
+
group?: number | undefined;
|
|
504
|
+
bypassToken?: string | undefined;
|
|
505
|
+
fallback?: string | undefined;
|
|
506
|
+
allowQuery?: string[] | undefined;
|
|
507
|
+
}, {
|
|
508
|
+
expiration: number | false;
|
|
509
|
+
group?: number | undefined;
|
|
510
|
+
bypassToken?: string | undefined;
|
|
511
|
+
fallback?: string | undefined;
|
|
512
|
+
allowQuery?: string[] | undefined;
|
|
513
|
+
}>;
|
|
514
|
+
type VercelOutputPrerenderConfig = z.infer<typeof vercelOutputPrerenderConfigSchema>;
|
|
515
|
+
|
|
516
|
+
type ViteVercelRewrite = Rewrite & {
|
|
517
|
+
enforce?: 'pre' | 'post';
|
|
518
|
+
};
|
|
519
|
+
type ViteVercelRedirect = Redirect & {
|
|
520
|
+
enforce?: 'pre' | 'post';
|
|
521
|
+
};
|
|
522
|
+
interface ViteVercelConfig {
|
|
523
|
+
/**
|
|
524
|
+
* How long Functions should be allowed to run for every request, in seconds.
|
|
525
|
+
* If left empty, default value for your plan will be used.
|
|
526
|
+
*/
|
|
527
|
+
defaultMaxDuration?: number;
|
|
528
|
+
/**
|
|
529
|
+
* Default expiration time (in seconds) for prerender functions.
|
|
530
|
+
* Defaults to 86400 seconds (24h).
|
|
531
|
+
* @see {@link https://vercel.com/docs/concepts/next.js/incremental-static-regeneration}
|
|
532
|
+
* @see {@link https://vercel.com/docs/build-output-api/v3#vercel-primitives/prerender-functions/configuration}
|
|
533
|
+
*/
|
|
534
|
+
expiration?: number;
|
|
535
|
+
/**
|
|
536
|
+
* Also known as Server Side Generation, or SSG.
|
|
537
|
+
* If present, this function is responsible to create static files in `.vercel/output/static`.
|
|
538
|
+
* Defaults to `false`, which disables prerendering.
|
|
539
|
+
*/
|
|
540
|
+
prerender?: ViteVercelPrerenderFn | false;
|
|
541
|
+
/**
|
|
542
|
+
* @see {@link https://vercel.com/docs/projects/project-configuration#rewrites}
|
|
543
|
+
*/
|
|
544
|
+
rewrites?: ViteVercelRewrite[];
|
|
545
|
+
/**
|
|
546
|
+
* @see {@link https://vercel.com/docs/projects/project-configuration#redirects}
|
|
547
|
+
*/
|
|
548
|
+
redirects?: ViteVercelRedirect[];
|
|
549
|
+
/**
|
|
550
|
+
* @see {@link https://vercel.com/docs/projects/project-configuration#cleanurls}
|
|
551
|
+
*/
|
|
552
|
+
cleanUrls?: boolean;
|
|
553
|
+
/**
|
|
554
|
+
* @see {@link https://vercel.com/docs/projects/project-configuration#trailingslash}
|
|
555
|
+
*/
|
|
556
|
+
trailingSlash?: boolean;
|
|
557
|
+
/**
|
|
558
|
+
* By default, all `api/*` endpoints are compiled under `.vercel/output/functions/api/*.func`.
|
|
559
|
+
* If others serverless functions need to be compiled under `.vercel/output/functions`, they should be added here.
|
|
560
|
+
* For instance, a framework can leverage this to have a generic ssr endpoint
|
|
561
|
+
* without requiring the user to write any code.
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* ```
|
|
565
|
+
* {
|
|
566
|
+
* additionalEndpoints: [
|
|
567
|
+
* {
|
|
568
|
+
* // can also be an Object representing an esbuild StdinOptions
|
|
569
|
+
* source: '/path/to/file.ts',
|
|
570
|
+
* // URL path of the handler, will be generated to `.vercel/output/functions/api/file.func/index.js`
|
|
571
|
+
* destination: '/api/file',
|
|
572
|
+
* }
|
|
573
|
+
* ]
|
|
574
|
+
* }
|
|
575
|
+
* ```
|
|
576
|
+
*/
|
|
577
|
+
additionalEndpoints?: ViteVercelApiEntry[];
|
|
578
|
+
/**
|
|
579
|
+
* Advanced configuration to override .vercel/output/config.json
|
|
580
|
+
* @see {@link https://vercel.com/docs/build-output-api/v3/configuration#configuration}
|
|
581
|
+
* @protected
|
|
582
|
+
*/
|
|
583
|
+
config?: Partial<Omit<VercelOutputConfig, 'version'>>;
|
|
584
|
+
/**
|
|
585
|
+
* ISR and SSG pages are mutually exclusive. If a page is found in both, ISR prevails.
|
|
586
|
+
* Keys are path relative to .vercel/output/functions directory, either without extension,
|
|
587
|
+
* or with `.prerender-config.json` extension.
|
|
588
|
+
* If you have multiple isr configurations pointing to the same underlying function, you can leverage the `symlink`
|
|
589
|
+
* property. See example below.
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```
|
|
593
|
+
* // Here `ssr_` means that a function is available under `.vercel/output/functions/ssr_.func`
|
|
594
|
+
* isr: {
|
|
595
|
+
* '/pages/a': { expiration: 15, symlink: 'ssr_', route: '^/a/.*$' },
|
|
596
|
+
* '/pages/b/c': { expiration: 15, symlink: 'ssr_', route: '^/b/c/.*$' },
|
|
597
|
+
* '/pages/d': { expiration: 15, symlink: 'ssr_', route: '^/d$' },
|
|
598
|
+
* '/pages/e': { expiration: 25 }
|
|
599
|
+
* }
|
|
600
|
+
* ```
|
|
601
|
+
*
|
|
602
|
+
* @protected
|
|
603
|
+
*/
|
|
604
|
+
isr?: Record<string, VercelOutputIsr> | (() => Promise<Record<string, VercelOutputIsr>> | Record<string, VercelOutputIsr>);
|
|
605
|
+
/**
|
|
606
|
+
* Defaults to `.vercel/output`. Mostly useful for testing purpose
|
|
607
|
+
* @protected
|
|
608
|
+
*/
|
|
609
|
+
outDir?: string;
|
|
610
|
+
}
|
|
611
|
+
interface VercelOutputIsr extends VercelOutputPrerenderConfig {
|
|
612
|
+
symlink?: string;
|
|
613
|
+
route?: string;
|
|
614
|
+
}
|
|
615
|
+
/**
|
|
616
|
+
* Keys are path relative to .vercel/output/static directory
|
|
617
|
+
*/
|
|
618
|
+
type ViteVercelPrerenderRoute = VercelOutputConfig['overrides'];
|
|
619
|
+
type ViteVercelPrerenderFn = (resolvedConfig: ResolvedConfig) => ViteVercelPrerenderRoute | Promise<ViteVercelPrerenderRoute>;
|
|
620
|
+
interface ViteVercelApiEntry {
|
|
621
|
+
/**
|
|
622
|
+
* Path to entry file, or stdin config
|
|
623
|
+
*/
|
|
624
|
+
source: string | StdinOptions;
|
|
625
|
+
/**
|
|
626
|
+
* Relative to `.vercel/output/functions`, without extension
|
|
627
|
+
*/
|
|
628
|
+
destination: string;
|
|
629
|
+
/**
|
|
630
|
+
* Override esbuild options
|
|
631
|
+
*/
|
|
632
|
+
buildOptions?: BuildOptions;
|
|
633
|
+
/**
|
|
634
|
+
* Automatically add a route for the function (mimics defaults Vercel behavior)
|
|
635
|
+
* Set to `false` to disable
|
|
636
|
+
*/
|
|
637
|
+
addRoute?: boolean;
|
|
638
|
+
/**
|
|
639
|
+
* Set to `true` to mark this function as an Edge Function
|
|
640
|
+
*/
|
|
641
|
+
edge?: boolean;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
declare function allPlugins(options?: {
|
|
645
|
+
smart?: boolean;
|
|
646
|
+
}): PluginOption[];
|
|
647
|
+
|
|
648
|
+
export { VercelOutputConfig, VercelOutputIsr, VercelOutputPrerenderConfig, VercelOutputVcConfig, ViteVercelApiEntry, ViteVercelConfig, ViteVercelPrerenderFn, ViteVercelPrerenderRoute, ViteVercelRedirect, ViteVercelRewrite, allPlugins as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-vercel",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
"module": "./dist/index.js",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"types": "./index.d.ts",
|
|
14
13
|
"import": "./dist/index.js",
|
|
15
14
|
"require": "./dist/index.cjs"
|
|
16
15
|
}
|
|
@@ -23,7 +22,7 @@
|
|
|
23
22
|
"peerDependencies": {
|
|
24
23
|
"vite": "^4.2.0",
|
|
25
24
|
"vite-plugin-ssr": "*",
|
|
26
|
-
"@vite-plugin-vercel/vike": "0.3.
|
|
25
|
+
"@vite-plugin-vercel/vike": "0.3.3"
|
|
27
26
|
},
|
|
28
27
|
"peerDependenciesMeta": {
|
|
29
28
|
"@vite-plugin-vercel/vike": {
|
|
@@ -35,17 +34,19 @@
|
|
|
35
34
|
},
|
|
36
35
|
"devDependencies": {
|
|
37
36
|
"@types/node": "^16.18.48",
|
|
38
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
39
|
-
"@typescript-eslint/parser": "^
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^6.6.0",
|
|
38
|
+
"@typescript-eslint/parser": "^6.6.0",
|
|
40
39
|
"eslint": "^8.48.0",
|
|
41
|
-
"tsup": "^
|
|
40
|
+
"tsup": "^7.2.0",
|
|
42
41
|
"typescript": "^5.2.2",
|
|
43
|
-
"vite": "^4.4.9"
|
|
42
|
+
"vite": "^4.4.9",
|
|
43
|
+
"vite-plugin-ssr": "^0.4.141",
|
|
44
|
+
"@vite-plugin-vercel/vike": "0.3.3"
|
|
44
45
|
},
|
|
45
46
|
"dependencies": {
|
|
46
47
|
"@brillout/libassert": "^0.5.8",
|
|
47
|
-
"@vercel/routing-utils": "^
|
|
48
|
-
"esbuild": "^0.
|
|
48
|
+
"@vercel/routing-utils": "^3.0.0",
|
|
49
|
+
"esbuild": "^0.19.2",
|
|
49
50
|
"fast-glob": "^3.3.1",
|
|
50
51
|
"zod": "^3.22.2"
|
|
51
52
|
},
|