vite-plugin-fake-server
Advanced tools
Comparing version 1.0.2 to 2.0.0-beta.0
{ | ||
"name": "vite-plugin-fake-server", | ||
"version": "1.0.2", | ||
"version": "2.0.0-beta.0", | ||
"type": "module", | ||
@@ -50,5 +50,5 @@ "license": "MIT", | ||
"dependencies": { | ||
"bundle-require": "^4.0.2", | ||
"chokidar": "^3.5.3", | ||
"fast-glob": "^3.3.1", | ||
"import-from-string": "^0.0.3", | ||
"path-to-regexp": "^6.2.1", | ||
@@ -55,0 +55,0 @@ "picocolors": "^1.0.0", |
@@ -15,3 +15,3 @@ # Vite-plugin-fake-server | ||
- ESM first. | ||
- Support `ts`, `js`, `mjs` files. | ||
- Support `ts`, `js`, `mjs`, `cjs`, `cts`, `mts` files. | ||
- Support multiple response methods —— [responseType](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/responseType). | ||
@@ -50,3 +50,3 @@ - Support custom response headers. | ||
By default, it is only valid in the development environment (`enableDev = true`), and monitors in real time (`watch = true`) all `ts`, `js`, `mjs` files in the mock folder under the current project. When the browser has For the real requested link, the terminal will automatically print the requested URL (Vite's `logLevel = "info"` and `clearScreen = true`). | ||
By default, it is only valid in the development environment (`enableDev = true`), and monitors in real time (`watch = true`) all `xxx.fake.{ts,js,mjs,cjs,cts,mts}` files in the fake(`include = fake`) folder under the current project. When the browser has For the real requested link, the terminal will automatically print the requested URL (`logger = true`). | ||
@@ -82,3 +82,3 @@ ## Examples | ||
### In `.ts` file | ||
### In `xxx.fake.ts` file | ||
@@ -102,3 +102,3 @@ ```ts | ||
{ | ||
url: "/mock/get-user-info", | ||
url: "/api/get-user-info", | ||
response: () => { | ||
@@ -126,3 +126,3 @@ return adminUserInfo; | ||
### In `.js` file | ||
### In `xxx.fake.js` file | ||
@@ -133,3 +133,3 @@ ```javascript | ||
{ | ||
url: "/mock/esm", | ||
url: "/api/esm", | ||
response: ({ query }) => { | ||
@@ -140,3 +140,3 @@ return { format: "ESM", query }; | ||
{ | ||
url: "/mock/response-text", | ||
url: "/api/response-text", | ||
response: (_, req) => { | ||
@@ -147,3 +147,3 @@ return req.headers["content-type"]; | ||
{ | ||
url: "/mock/post", | ||
url: "/api/post", | ||
method: "POST", | ||
@@ -157,7 +157,7 @@ response: ({ body }) => { | ||
### In `.mjs` file | ||
### In `xxx.fake.mjs` file | ||
```javascript | ||
export default { | ||
url: "/mock/mjs", | ||
url: "/api/mjs", | ||
method: "POST", | ||
@@ -181,5 +181,5 @@ statusCode: 200, | ||
Type: `string`\ | ||
Default: `"mock"` | ||
Default: `"fake"` | ||
Set the folder where the mock/fake `ts`, `js`, `mjs` files is stored. | ||
Set the folder where the fake `xxx.fake.{ts,js,mjs,cjs,cts,mts}` files is stored. | ||
@@ -195,2 +195,9 @@ ##### exclude | ||
##### infixName | ||
Type: `string | boolean`\ | ||
Default: `"fake"` | ||
Set the infix name used in the fake file name. | ||
##### watch | ||
@@ -203,8 +210,25 @@ | ||
##### logger | ||
Type: `boolean`\ | ||
Default: `true` | ||
Set whether to display the request log on the console. | ||
In order to maintain logs and screen clearing strategies consistent with Vite style on the terminal, the vite-plugin-fake-server plugin will automatically read the following three parameters in the Vite configuration file or in the Vite command line. | ||
- [loglevel](https://vitejs.dev/config/shared-options.html#loglevel) | ||
- [customlogger](https://vitejs.dev/config/shared-options.html#customlogger) | ||
- [clearScreen](https://vitejs.dev/config/shared-options.html#clearScreen) | ||
A preview image: | ||
![shapes at 23-10-24 15 23 18](https://github.com/condorheroblog/vite-plugin-fake-server/assets/47056890/a6b11fcb-ee30-40a5-9beb-b1d9a0a51b39) | ||
##### extensions | ||
Type: `string[]`\ | ||
Default: `["ts", "js", "mjs"]` | ||
Default: `["ts", "js", "mjs", "cjs", "cts", "mts"]` | ||
Set the mock files extensions. | ||
Set the fake files extensions. | ||
@@ -250,3 +274,3 @@ ##### timeout | ||
> ⚠️ The node module cannot be used in the mock file, otherwise the production environment will fail.As an alternative to keep consistent with the development environment, you can build a standalone deployment server, see [build option](https://github.com/condorheroblog/vite-plugin-fake-server#build). | ||
> ⚠️ The node module cannot be used in the fake file, otherwise the production environment will fail.As an alternative to keep consistent with the development environment, you can build a standalone deployment server, see [build option](https://github.com/condorheroblog/vite-plugin-fake-server#build). | ||
@@ -284,3 +308,3 @@ Compared with the development environment, the API interface defined in the production environment does not have a `rawResponse` function. The response function does not have the second parameter `request` and the third parameter `response`. | ||
* directory exists, it will be removed before the build. | ||
* @default "mockServer" | ||
* @default "fakeServer" | ||
*/ | ||
@@ -291,14 +315,2 @@ outDir?: string; | ||
#### Shared Options | ||
In order to maintain logs and screen clearing strategies consistent with Vite style on the terminal, the vite-plugin-fake-server plugin will automatically read the following three parameters in the Vite configuration file or in the Vite command line. | ||
- [loglevel](https://vitejs.dev/config/shared-options.html#loglevel) | ||
- [customlogger](https://vitejs.dev/config/shared-options.html#customlogger) | ||
- [clearScreen](https://vitejs.dev/config/shared-options.html#clearScreen) | ||
A preview image: | ||
![shapes at 23-10-24 15 23 18](https://github.com/condorheroblog/vite-plugin-fake-server/assets/47056890/a6b11fcb-ee30-40a5-9beb-b1d9a0a51b39) | ||
## Principle | ||
@@ -305,0 +317,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115503
2032
348
1
+ Addedimport-from-string@^0.0.3
+ Added@esbuild/aix-ppc64@0.19.12(transitive)
+ Added@esbuild/android-arm@0.19.12(transitive)
+ Added@esbuild/android-arm64@0.19.12(transitive)
+ Added@esbuild/android-x64@0.19.12(transitive)
+ Added@esbuild/darwin-arm64@0.19.12(transitive)
+ Added@esbuild/darwin-x64@0.19.12(transitive)
+ Added@esbuild/freebsd-arm64@0.19.12(transitive)
+ Added@esbuild/freebsd-x64@0.19.12(transitive)
+ Added@esbuild/linux-arm@0.19.12(transitive)
+ Added@esbuild/linux-arm64@0.19.12(transitive)
+ Added@esbuild/linux-ia32@0.19.12(transitive)
+ Added@esbuild/linux-loong64@0.19.12(transitive)
+ Added@esbuild/linux-mips64el@0.19.12(transitive)
+ Added@esbuild/linux-ppc64@0.19.12(transitive)
+ Added@esbuild/linux-riscv64@0.19.12(transitive)
+ Added@esbuild/linux-s390x@0.19.12(transitive)
+ Added@esbuild/linux-x64@0.19.12(transitive)
+ Added@esbuild/netbsd-x64@0.19.12(transitive)
+ Added@esbuild/openbsd-x64@0.19.12(transitive)
+ Added@esbuild/sunos-x64@0.19.12(transitive)
+ Added@esbuild/win32-arm64@0.19.12(transitive)
+ Added@esbuild/win32-ia32@0.19.12(transitive)
+ Added@esbuild/win32-x64@0.19.12(transitive)
+ Addedesbuild@0.19.12(transitive)
+ Addedimport-from-string@0.0.3(transitive)
+ Addedimport-meta-resolve@3.1.1(transitive)
- Removedbundle-require@^4.0.2
- Removed@esbuild/aix-ppc64@0.24.0(transitive)
- Removed@esbuild/android-arm@0.24.0(transitive)
- Removed@esbuild/android-arm64@0.24.0(transitive)
- Removed@esbuild/android-x64@0.24.0(transitive)
- Removed@esbuild/darwin-arm64@0.24.0(transitive)
- Removed@esbuild/darwin-x64@0.24.0(transitive)
- Removed@esbuild/freebsd-arm64@0.24.0(transitive)
- Removed@esbuild/freebsd-x64@0.24.0(transitive)
- Removed@esbuild/linux-arm@0.24.0(transitive)
- Removed@esbuild/linux-arm64@0.24.0(transitive)
- Removed@esbuild/linux-ia32@0.24.0(transitive)
- Removed@esbuild/linux-loong64@0.24.0(transitive)
- Removed@esbuild/linux-mips64el@0.24.0(transitive)
- Removed@esbuild/linux-ppc64@0.24.0(transitive)
- Removed@esbuild/linux-riscv64@0.24.0(transitive)
- Removed@esbuild/linux-s390x@0.24.0(transitive)
- Removed@esbuild/linux-x64@0.24.0(transitive)
- Removed@esbuild/netbsd-x64@0.24.0(transitive)
- Removed@esbuild/openbsd-arm64@0.24.0(transitive)
- Removed@esbuild/openbsd-x64@0.24.0(transitive)
- Removed@esbuild/sunos-x64@0.24.0(transitive)
- Removed@esbuild/win32-arm64@0.24.0(transitive)
- Removed@esbuild/win32-ia32@0.24.0(transitive)
- Removed@esbuild/win32-x64@0.24.0(transitive)
- Removedbundle-require@4.2.1(transitive)
- Removedesbuild@0.24.0(transitive)
- Removedload-tsconfig@0.2.5(transitive)