@netlify/vite-plugin 2.1.1 → 2.1.3
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 +17 -0
- package/dist/main.js +15 -13
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -5,6 +5,22 @@
|
|
|
5
5
|
|
|
6
6
|
A Vite plugin that integrates with Netlify's platform features.
|
|
7
7
|
|
|
8
|
+
## 🚧 Feature Support
|
|
9
|
+
|
|
10
|
+
| Feature | Supported |
|
|
11
|
+
| ---------------------- | --------- |
|
|
12
|
+
| Functions | ✅ Yes |
|
|
13
|
+
| Edge Functions | ✅ Yes |
|
|
14
|
+
| Blobs | ✅ Yes |
|
|
15
|
+
| Cache API | ✅ Yes |
|
|
16
|
+
| Redirects and Rewrites | ✅ Yes |
|
|
17
|
+
| Headers | ✅ Yes |
|
|
18
|
+
| Environment Variables | ✅ Yes |
|
|
19
|
+
| Image CDN | ❌ No |
|
|
20
|
+
|
|
21
|
+
> Note: Missing features will be added incrementally. This module is **not** intended to be a full replacement for the
|
|
22
|
+
> Netlify CLI.
|
|
23
|
+
|
|
8
24
|
## Installation
|
|
9
25
|
|
|
10
26
|
```bash
|
|
@@ -18,6 +34,7 @@ The plugin accepts the following options:
|
|
|
18
34
|
- `middleware` (boolean, default: `true`): Attach a Vite middleware that intercepts requests and handles them in the
|
|
19
35
|
same way as the Netlify production environment
|
|
20
36
|
- `blobs`: Configure blob storage functionality
|
|
37
|
+
- `edgeFunctions`: Configure edge functions
|
|
21
38
|
- `functions`: Configure serverless functions
|
|
22
39
|
- `headers`: Configure response headers
|
|
23
40
|
- `redirects`: Configure URL redirects
|
package/dist/main.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
// src/main.ts
|
|
2
2
|
import process from "process";
|
|
3
3
|
import { NetlifyDev } from "@netlify/dev";
|
|
4
|
+
import { netlifyCommand } from "@netlify/dev-utils";
|
|
4
5
|
|
|
5
6
|
// src/lib/logger.ts
|
|
6
|
-
import
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
warn: (...data) => data.length === 0 ? console.warn(...data) : console.warn(banner, ...data)
|
|
13
|
-
};
|
|
7
|
+
import { netlifyBanner } from "@netlify/dev-utils";
|
|
8
|
+
var createLoggerFromViteLogger = (viteLogger) => ({
|
|
9
|
+
error: (msg) => viteLogger.error(msg ?? "", { timestamp: true, environment: netlifyBanner }),
|
|
10
|
+
log: (msg) => viteLogger.info(msg ?? "", { timestamp: true, environment: netlifyBanner }),
|
|
11
|
+
warn: (msg) => viteLogger.warn(msg ?? "", { timestamp: true, environment: netlifyBanner })
|
|
12
|
+
});
|
|
14
13
|
|
|
15
14
|
// src/lib/reqres.ts
|
|
16
15
|
import { Readable } from "stream";
|
|
@@ -41,6 +40,7 @@ function netlify(options = {}) {
|
|
|
41
40
|
const plugin = {
|
|
42
41
|
name: "vite-plugin-netlify",
|
|
43
42
|
async configureServer(viteDevServer) {
|
|
43
|
+
const logger = createLoggerFromViteLogger(viteDevServer.config.logger);
|
|
44
44
|
const { port } = viteDevServer.config.server;
|
|
45
45
|
const { blobs, edgeFunctions, functions, middleware = true, redirects, staticFiles } = options;
|
|
46
46
|
const netlifyDev = new NetlifyDev({
|
|
@@ -57,11 +57,7 @@ function netlify(options = {}) {
|
|
|
57
57
|
projectRoot: viteDevServer.config.root
|
|
58
58
|
});
|
|
59
59
|
await netlifyDev.start();
|
|
60
|
-
|
|
61
|
-
logger.log(
|
|
62
|
-
"Linking this project to a Netlify site lets you deploy your site, use any environment variables defined on your team and site and much more. Run `npx netlify init` to get started."
|
|
63
|
-
);
|
|
64
|
-
}
|
|
60
|
+
logger.log("Environment loaded");
|
|
65
61
|
if (middleware) {
|
|
66
62
|
viteDevServer.middlewares.use(async function netlifyPreMiddleware(nodeReq, nodeRes, next) {
|
|
67
63
|
const headers = {};
|
|
@@ -80,6 +76,12 @@ function netlify(options = {}) {
|
|
|
80
76
|
}
|
|
81
77
|
next();
|
|
82
78
|
});
|
|
79
|
+
logger.log(`Middleware loaded. Emulating features: ${netlifyDev.getEnabledFeatures().join(", ")}.`);
|
|
80
|
+
}
|
|
81
|
+
if (!netlifyDev.siteIsLinked) {
|
|
82
|
+
logger.log(
|
|
83
|
+
`\u{1F4AD} Linking this project to a Netlify site lets you deploy your site, use any environment variables defined on your team and site and much more. Run ${netlifyCommand("npx netlify init")} to get started.`
|
|
84
|
+
);
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/vite-plugin",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Vite plugin with a local emulation of the Netlify environment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"vitest": "^3.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@netlify/dev": "4.1.
|
|
39
|
+
"@netlify/dev": "4.1.3",
|
|
40
|
+
"@netlify/dev-utils": "^3.1.1",
|
|
40
41
|
"chalk": "^5.4.1"
|
|
41
42
|
},
|
|
42
43
|
"peerDependencies": {
|