vite-plugin-vercel 0.0.6 → 0.0.7

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 ADDED
@@ -0,0 +1,56 @@
1
+ # vite-plugin-vercel
2
+
3
+ This is a **Work In Progress** Vercel adapter for [`vite`](https://vitejs.dev/).
4
+
5
+ ## Usage
6
+
7
+ Install as a dev dependency and add it to your Vite config like this:
8
+
9
+ ```ts
10
+ import { defineConfig } from 'vite';
11
+ import vercel from 'vite-plugin-vercel';
12
+ import ssr from 'vite-plugin-ssr';
13
+
14
+ export default defineConfig({
15
+ plugins: [ssr(), vercel()],
16
+ });
17
+ ```
18
+
19
+ ### Usage with vite-plugin-ssr
20
+
21
+ [vite-plugin-ssr](https://vite-plugin-ssr.com/) will support this plugin when stable.
22
+ In the meantime, you can add experimental support yourself.
23
+
24
+ First copy [prerender](../../prerender) folder to the root of your project.
25
+ Then, update your vercel config:
26
+
27
+ ```ts
28
+ // vercel.config.ts
29
+ // A TS config is prefered if your project is of { type: "module" }
30
+
31
+ import module from 'module';
32
+ import { defineConfig } from 'vite';
33
+ import ssr from 'vite-plugin-ssr/plugin';
34
+ import vercel from 'vite-plugin-vercel';
35
+
36
+ // FIX esbuild bug https://github.com/evanw/esbuild/pull/2067
37
+ // probably not necessary when `./prerender/vite-plugin-ssr` will be included in `vite-plugin-ssr`
38
+ // eslint-disable-next-line no-undef
39
+ globalThis.require = module.createRequire(import.meta.url);
40
+
41
+ export default defineConfig(async ({ command, mode }) => {
42
+ // Dynamic import to bypass esbuild compilation issue.
43
+ // If you are not using ESM, could me move as a top synchronous import
44
+ const vitePluginSsrVercelPlugin = await import('./prerender/vite-plugin-ssr');
45
+
46
+ return {
47
+ plugins: [ssr(), vercel(), vitePluginSsrVercelPlugin.default()],
48
+ build: {
49
+ polyfillDynamicImport: false,
50
+ },
51
+ vercel: {
52
+ // Tweak what you need, check TS definition for details
53
+ },
54
+ };
55
+ });
56
+ ```
package/dist/index.cjs CHANGED
@@ -385,8 +385,8 @@ function vercelPlugin() {
385
385
  resolvedConfig = config;
386
386
  },
387
387
  async buildStart() {
388
- if (process.env.VERCEL_ENV === "production" && !process.env.ENABLE_FILE_SYSTEM_API) {
389
- throw new Error("Missing ENABLE_FILE_SYSTEM_API=1 to your environment variables in your project settings");
388
+ if (process.env.VERCEL_ENV === "production" && !process.env.ENABLE_VC_BUILD) {
389
+ throw new Error("Missing ENABLE_VC_BUILD=1 to your environment variables in your project settings");
390
390
  }
391
391
  if (!resolvedConfig.build.ssr) {
392
392
  await cleanOutputDirectory(resolvedConfig);
package/dist/index.js CHANGED
@@ -362,8 +362,8 @@ function vercelPlugin() {
362
362
  resolvedConfig = config;
363
363
  },
364
364
  async buildStart() {
365
- if (process.env.VERCEL_ENV === "production" && !process.env.ENABLE_FILE_SYSTEM_API) {
366
- throw new Error("Missing ENABLE_FILE_SYSTEM_API=1 to your environment variables in your project settings");
365
+ if (process.env.VERCEL_ENV === "production" && !process.env.ENABLE_VC_BUILD) {
366
+ throw new Error("Missing ENABLE_VC_BUILD=1 to your environment variables in your project settings");
367
367
  }
368
368
  if (!resolvedConfig.build.ssr) {
369
369
  await cleanOutputDirectory(resolvedConfig);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vercel",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
package/readme.md DELETED
@@ -1,28 +0,0 @@
1
- # vite-plugin-vercel
2
-
3
- This is a wip Vercel adapter for [`vite`](https://vitejs.dev/).
4
-
5
- ## Usage
6
-
7
- Install as a dev dependency and add it to your Vite config like this:
8
-
9
- ```ts
10
- import { defineConfig } from 'vite';
11
- import vercel from 'vite-plugin-vercel';
12
- import ssr from 'vite-plugin-ssr';
13
-
14
- export default defineConfig({
15
- plugins: [
16
- ssr(),
17
- vercel({
18
- dynamicRoutes: [
19
- {
20
- ssr: true,
21
- page: '/ssr',
22
- regex: '/((?!assets/)(?!api/).*)',
23
- },
24
- ],
25
- }),
26
- ],
27
- });
28
- ```