vite-plugin-mock-dev-server
Advanced tools
Comparing version 0.3.14 to 0.3.15
@@ -11,3 +11,2 @@ // src/mockMiddleware.ts | ||
import { pathToFileURL } from "url"; | ||
import { createFilter } from "@rollup/pluginutils"; | ||
import chokidar from "chokidar"; | ||
@@ -17,2 +16,3 @@ import { build } from "esbuild"; | ||
import JSON5 from "json5"; | ||
import { createFilter } from "vite"; | ||
@@ -55,2 +55,3 @@ // src/utils.ts | ||
super(); | ||
this.options = options; | ||
this.moduleCache = /* @__PURE__ */ new Map(); | ||
@@ -60,3 +61,2 @@ this.moduleDeps = /* @__PURE__ */ new Map(); | ||
this.moduleType = "cjs"; | ||
this.options = options; | ||
this.cwd = options.cwd || process.cwd(); | ||
@@ -246,7 +246,2 @@ try { | ||
var _a; | ||
const userDefine = {}; | ||
for (const key in this.options.define) { | ||
const val = this.options.define[key]; | ||
userDefine[key] = typeof val === "string" ? val : JSON.stringify(val); | ||
} | ||
try { | ||
@@ -262,3 +257,3 @@ const result = await build({ | ||
format: isESM ? "esm" : "cjs", | ||
define: userDefine, | ||
define: this.options.define, | ||
plugins: [ | ||
@@ -351,6 +346,13 @@ { | ||
const exclude = isArray(options.exclude) ? options.exclude : [options.exclude]; | ||
const define = {}; | ||
if (config.define) { | ||
for (const key in config.define) { | ||
const val = config.define[key]; | ||
define[key] = typeof val === "string" ? val : JSON.stringify(val); | ||
} | ||
} | ||
const loader = new MockLoader({ | ||
include, | ||
exclude, | ||
define: config.define || {} | ||
define | ||
}); | ||
@@ -357,0 +359,0 @@ await loader.load(); |
{ | ||
"name": "vite-plugin-mock-dev-server", | ||
"type": "module", | ||
"version": "0.3.14", | ||
"packageManager": "pnpm@7.18.2", | ||
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo)", | ||
"license": "GPL-3.0", | ||
"homepage": "https://vite-plugin-mock-dev-server.netlify.app", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pengzhanbo/vite-plugin-mock-dev-server" | ||
}, | ||
"version": "0.3.15", | ||
"keywords": [ | ||
@@ -20,2 +11,10 @@ "vite", | ||
], | ||
"homepage": "https://vite-plugin-mock-dev-server.netlify.app", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/pengzhanbo/vite-plugin-mock-dev-server" | ||
}, | ||
"license": "GPL-3.0", | ||
"author": "pengzhanbo <q942450674@outlook.com> (https://github.com/pengzhanbo)", | ||
"type": "module", | ||
"exports": { | ||
@@ -33,24 +32,4 @@ ".": { | ||
], | ||
"engines": { | ||
"node": "^14.18.0 || >=16" | ||
}, | ||
"tsup": { | ||
"entry": [ | ||
"src/index.ts" | ||
], | ||
"sourcemap": false, | ||
"dts": true, | ||
"splitting": false, | ||
"clean": true, | ||
"format": [ | ||
"esm", | ||
"cjs" | ||
] | ||
}, | ||
"prettier": "@pengzhanbo/prettier-config", | ||
"peerDependencies": { | ||
"vite": ">=3.0.0" | ||
}, | ||
"dependencies": { | ||
"@rollup/pluginutils": "^5.0.2", | ||
"chokidar": "^3.5.3", | ||
@@ -66,4 +45,4 @@ "co-body": "^6.1.0", | ||
"devDependencies": { | ||
"@pengzhanbo/eslint-config-ts": "^0.3.1", | ||
"@pengzhanbo/prettier-config": "^0.3.1", | ||
"@pengzhanbo/eslint-config-ts": "^0.3.2", | ||
"@pengzhanbo/prettier-config": "^0.3.2", | ||
"@types/co-body": "^6.1.0", | ||
@@ -74,2 +53,3 @@ "@types/debug": "^4.1.7", | ||
"bumpp": "^8.2.1", | ||
"conventional-changelog-cli": "^2.2.2", | ||
"eslint": "^8.31.0", | ||
@@ -82,14 +62,35 @@ "mockjs": "^1.1.0", | ||
"vite-plugin-mock-dev-server": "file:", | ||
"vitepress": "1.0.0-alpha.32", | ||
"vitepress": "1.0.0-alpha.35", | ||
"vue": "^3.2.45" | ||
}, | ||
"peerDependencies": { | ||
"vite": ">=3.0.0" | ||
}, | ||
"packageManager": "pnpm@7.18.2", | ||
"engines": { | ||
"node": "^14.18.0 || >=16" | ||
}, | ||
"tsup": { | ||
"entry": [ | ||
"src/index.ts" | ||
], | ||
"sourcemap": false, | ||
"dts": true, | ||
"splitting": false, | ||
"clean": true, | ||
"format": [ | ||
"esm", | ||
"cjs" | ||
] | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"dev": "DEBUG=vite:plugin-mock-dev-server vite example --config ./example/vite.config.ts", | ||
"build": "tsup", | ||
"docs:build": "vitepress build docs", | ||
"docs:dev": "vitepress dev docs", | ||
"docs:build": "vitepress build docs", | ||
"docs:preview": "vitepress preview docs", | ||
"lint": "eslint .", | ||
"release": "bumpp package.json --commit --push --tag && pnpm publish --access public" | ||
"release:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", | ||
"release": "bumpp package.json --execute=\"pnpm release:changelog\" --commit --all --push --tag && pnpm publish --access public" | ||
} | ||
} |
@@ -5,3 +5,5 @@ # vite-plugin-mock-dev-server | ||
<br> | ||
<p align="center">Vite Plugin for API mock dev server.</p> | ||
<p align="center"> | ||
<b>Vite Plugin for API mock dev server.</b> | ||
</p> | ||
@@ -14,2 +16,3 @@ <br> | ||
<img alt="GitHub" src="https://img.shields.io/github/license/pengzhanbo/vite-plugin-mock-dev-server?style=flat-square"> | ||
<img alt="npm" src="https://img.shields.io/npm/dm/vite-plugin-mock-dev-server?style=flat-square"> | ||
</p> | ||
@@ -130,3 +133,3 @@ <br> | ||
When you configure the mock files to be read, the files you want to exclude can be a directory, a glob, or an array | ||
When you configure the mock files to be read, the files you want to exclude can be a directory, glob, or array | ||
@@ -138,3 +141,2 @@ Default: | ||
'**/test/**', | ||
'**/cypress/**', | ||
'src/**', | ||
@@ -300,3 +302,3 @@ '**/.vscode/**', | ||
#### Example 2: | ||
Match `/api/test` ,And returns a fixed content data | ||
Match `/api/test` ,And returns a static content data | ||
```ts | ||
@@ -303,0 +305,0 @@ export default defineMock({ |
@@ -5,3 +5,5 @@ # vite-plugin-mock-dev-server | ||
<br> | ||
<p align="center">vite mock开发服务(mock-dev-server)插件。</p> | ||
<p align="center"> | ||
<b>vite mock开发服务(mock-dev-server)插件。</b> | ||
</p> | ||
@@ -16,2 +18,3 @@ <p align="center">在 vite 开发环境中,注入一个 mock-dev-server。</p> | ||
<img alt="GitHub" src="https://img.shields.io/github/license/pengzhanbo/vite-plugin-mock-dev-server?style=flat-square"> | ||
<img alt="npm" src="https://img.shields.io/npm/dm/vite-plugin-mock-dev-server?style=flat-square"> | ||
</p> | ||
@@ -33,3 +36,3 @@ <br> | ||
- 📦 自动加载 mock 文件 | ||
- 🎨 可选择你喜欢的任意用于生成mock数据库,如 `mockjs`,或者不是用其他库 | ||
- 🎨 可选择你喜欢的任意用于生成mock数据库,如 `mockjs`,或者不使用其他库 | ||
- 📥 路径规则匹配,请求参数匹配 | ||
@@ -36,0 +39,0 @@ - ⚙️ 随意开启或关闭对某个接口的 mock配置 |
Sorry, the diff of this file is not supported yet
94299
9
1126
478
17
- Removed@rollup/pluginutils@^5.0.2
- Removed@rollup/pluginutils@5.1.4(transitive)
- Removedestree-walker@2.0.2(transitive)
- Removedpicomatch@4.0.2(transitive)