[
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\ncharset = utf-8\nend_of_line = lf\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n\n[*.md]\ninsert_final_newline = false\ntrim_trailing_whitespace = false\n\n[*.{js,jsx,json,ts,tsx,yml}]\nindent_size = 2\nindent_style = space\n"
  },
  {
    "path": ".eslintignore",
    "content": "dist\nnode_modules\nexample\n"
  },
  {
    "path": ".eslintrc.js",
    "content": "module.exports = {\n  root: true,\n  env: {\n    browser: true,\n    es2021: true,\n    es6: true,\n    node: true,\n  },\n  extends: [\n    'eslint:recommended',\n    'plugin:@typescript-eslint/recommended',\n    'prettier',\n  ],\n  parser: '@typescript-eslint/parser',\n  parserOptions: {\n    ecmaVersion: 12,\n    sourceType: 'module',\n  },\n  plugins: ['@typescript-eslint'],\n  rules: {\n    'no-console': 'off',\n    '@typescript-eslint/no-var-requires': 'off',\n    '@typescript-eslint/no-non-null-assertion': 'off',\n    '@typescript-eslint/ban-ts-comment': 'off',\n    '@typescript-eslint/explicit-module-boundary-types': 'off',\n    '@typescript-eslint/no-explicit-any': 'off',\n    '@typescript-eslint/no-unused-vars': 'off',\n  },\n}\n"
  },
  {
    "path": ".github/dependabot.yml",
    "content": "version: 2\nupdates:\n  - package-ecosystem: 'yarn'\n    directory: '/'\n    schedule:\n      interval: 'daily'\n"
  },
  {
    "path": ".github/workflows/publish.yml",
    "content": "name: Npm Publish\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  publish-npm:\n    if: \"contains(github.event.head_commit.message, 'release')\"\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v2\n\n      - name: use Node.js 20\n        uses: actions/setup-node@v1\n        with:\n          registry-url: https://registry.npmjs.org/\n          node-version: 20\n\n      - name: pnpm install and publish\n        run: |\n          npm i -g pnpm\n          pnpm install\n          pnpm publish --filter=./packages/vite-plugin-mock\n\n        env:\n          NODE_AUTH_TOKEN: ${{secrets.npm_token}}\n"
  },
  {
    "path": ".github/workflows/release.yml",
    "content": "name: Create Release\n\non:\n  push:\n    tags:\n      - v*\n\njobs:\n  build:\n    name: Create Release\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@master\n\n      - name: Create Release for Tag\n        id: release_tag\n        uses: yyx990803/release-tag@master\n        env:\n          GITHUB_TOKEN: ${{ secrets.OPER_TOKEN }}\n        with:\n          tag_name: ${{ github.ref }}\n          body: |\n            Please refer to [CHANGELOG.md](https://github.com/anncwb/vite-plugin-mock/blob/main/CHANGELOG.md) for details.\n      # - name: npm install and create changeLog\n      #   run: |\n      #     npm install\n      #     npm run log\n"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\n.DS_Store\ndist\nes\n.npmrc\n.cache\n\ntest/upload-server/static\n\n.local\n# local env files\n.env.local\n.env.*.local\n\n# Log files\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\npnpm-debug.log*\n\n# Editor directories and files\n.idea\n# .vscode\n*.suo\n*.ntvs*\n*.njsproj\n*.sln\n*.sw?\n\ncoverage\n"
  },
  {
    "path": ".husky/.gitignore",
    "content": "_\n"
  },
  {
    "path": ".husky/commit-msg",
    "content": "#!/bin/sh\n\n# shellcheck source=./_/husky.sh\n. \"$(dirname \"$0\")/_/husky.sh\"\n\nnpx --no-install commitlint --edit \"$1\"\n"
  },
  {
    "path": ".husky/common.sh",
    "content": "#!/bin/sh\ncommand_exists () {\n  command -v \"$1\" >/dev/null 2>&1\n}\n\n# Workaround for Windows 10, Git Bash and Yarn\nif command_exists winpty && test -t 1; then\n  exec < /dev/tty\nfi\n"
  },
  {
    "path": ".husky/lintstagedrc.js",
    "content": "module.exports = {\n  '*.{js,jsx,ts,tsx}': ['eslint --fix', 'prettier --write'],\n  '{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': ['prettier --write--parser json'],\n  'package.json': ['prettier --write'],\n  '*.md': ['prettier --write'],\n}\n"
  },
  {
    "path": ".husky/pre-commit",
    "content": "#!/bin/sh\n. \"$(dirname \"$0\")/_/husky.sh\"\n. \"$(dirname \"$0\")/common.sh\"\n\n[ -n \"$CI\" ] && exit 0\n\n# Format and submit code according to lintstagedrc.js configuration\nnpm run lint:lint-staged\n"
  },
  {
    "path": ".prettierignore",
    "content": "dist/\nnode_modules\n"
  },
  {
    "path": ".vscode/extensions.json",
    "content": "{\n  \"recommendations\": [\n    \"octref.vetur\",\n    \"dbaeumer.vscode-eslint\",\n    \"stylelint.vscode-stylelint\",\n    \"esbenp.prettier-vscode\",\n    \"mrmlnc.vscode-less\",\n    \"lokalise.i18n-ally\",\n    \"antfu.iconify\",\n    \"mikestead.dotenv\",\n    \"heybourn.headwind\"\n  ]\n}\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\n  \"typescript.tsdk\": \"./node_modules/typescript/lib\",\n  \"typescript.enablePromptUseWorkspaceTsdk\": true,\n  //===========================================\n  //============= Editor ======================\n  //===========================================\n  \"explorer.openEditors.visible\": 0,\n  \"editor.tabSize\": 2,\n  \"editor.defaultFormatter\": \"esbenp.prettier-vscode\",\n  \"diffEditor.ignoreTrimWhitespace\": false,\n  //===========================================\n  //============= Other =======================\n  //===========================================\n  \"breadcrumbs.enabled\": true,\n  \"open-in-browser.default\": \"chrome\",\n  //===========================================\n  //============= files =======================\n  //===========================================\n  \"files.eol\": \"\\n\",\n  \"search.exclude\": {\n    \"**/node_modules\": true,\n    \"**/*.log\": true,\n    \"**/*.log*\": true,\n    \"**/bower_components\": true,\n    \"**/dist\": true,\n    \"**/elehukouben\": true,\n    \"**/.git\": true,\n    \"**/.gitignore\": true,\n    \"**/.svn\": true,\n    \"**/.DS_Store\": true,\n    \"**/.idea\": true,\n    \"**/.vscode\": false,\n    \"**/yarn.lock\": true,\n    \"**/tmp\": true,\n    \"out\": true,\n    \"dist\": true,\n    \"node_modules\": true,\n    \"CHANGELOG.md\": true,\n    \"examples\": true,\n    \"res\": true,\n    \"screenshots\": true,\n    \"yarn-error.log\": true,\n    \"**/.yarn\": true\n  },\n  \"files.exclude\": {\n    \"**/.cache\": true,\n    \"**/.editorconfig\": true,\n    \"**/.eslintcache\": true,\n    \"**/bower_components\": true,\n    \"**/.idea\": true,\n    \"**/tmp\": true,\n    \"**/.git\": true,\n    \"**/.svn\": true,\n    \"**/.hg\": true,\n    \"**/CVS\": true,\n    \"**/.DS_Store\": true\n  },\n  \"files.watcherExclude\": {\n    \"**/.git/objects/**\": true,\n    \"**/.git/subtree-cache/**\": true,\n    \"**/.vscode/**\": true,\n    \"**/node_modules/**\": true,\n    \"**/tmp/**\": true,\n    \"**/bower_components/**\": true,\n    \"**/dist/**\": true,\n    \"**/yarn.lock\": true\n  },\n  \"stylelint.enable\": true,\n  \"stylelint.packageManager\": \"yarn\",\n  \"liveServer.settings.donotShowInfoMsg\": true,\n  \"telemetry.enableCrashReporter\": false,\n  \"workbench.settings.enableNaturalLanguageSearch\": false,\n  \"path-intellisense.mappings\": {\n    \"/@/\": \"${workspaceRoot}/src\"\n  },\n  \"prettier.requireConfig\": true,\n  \"typescript.updateImportsOnFileMove.enabled\": \"always\",\n  \"workbench.sideBar.location\": \"left\",\n  \"[javascriptreact]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[typescript]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[typescriptreact]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[html]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[css]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[less]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[scss]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"[markdown]\": {\n    \"editor.defaultFormatter\": \"esbenp.prettier-vscode\"\n  },\n  \"editor.codeActionsOnSave\": {\n    \"source.fixAll.eslint\": true\n  },\n  \"[vue]\": {\n    \"editor.codeActionsOnSave\": {\n      \"source.fixAll.eslint\": false\n    }\n  },\n  \"i18n-ally.localesPaths\": [\"src/locales/lang\"],\n  \"i18n-ally.keystyle\": \"nested\",\n  \"i18n-ally.sortKeys\": true,\n  \"i18n-ally.namespace\": true,\n  \"i18n-ally.pathMatcher\": \"{locale}/{namespaces}.{ext}\",\n  \"i18n-ally.enabledParsers\": [\"ts\"],\n  \"i18n-ally.sourceLanguage\": \"en\",\n  \"i18n-ally.displayLanguage\": \"zh-CN\",\n  \"i18n-ally.enabledFrameworks\": [\"vue\", \"react\"],\n  \"cSpell.words\": [\n    \"vben\",\n    \"windi\",\n    \"browserslist\",\n    \"tailwindcss\",\n    \"esnext\",\n    \"antv\",\n    \"tinymce\",\n    \"qrcode\",\n    \"sider\",\n    \"pinia\",\n    \"sider\",\n    \"nprogress\",\n    \"INTLIFY\",\n    \"stylelint\",\n    \"esno\",\n    \"vitejs\",\n    \"sortablejs\",\n    \"mockjs\",\n    \"codemirror\",\n    \"iconify\",\n    \"commitlint\",\n    \"vditor\",\n    \"echarts\",\n    \"cropperjs\",\n    \"logicflow\",\n    \"vueuse\",\n    \"zxcvbn\",\n    \"lintstagedrc\",\n    \"brotli\",\n    \"tailwindcss\",\n    \"sider\"\n  ]\n}\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "## [3.0.0]\n\n### Breaking Change\n\n- Remove the `localEnabled` and `prodEnabled` configuration and use the `enable` configuration instead, no longer distinguishing the environment\n- Remove the `injectFile`、`injectCode` and `supportTs` configuration\n- Minimum requirement NodeJs 16\n- Production Environment Syntax Changes\n\n```ts\n// vite-plugin-mock/es/createProdMockServer => vite-plugin-mock/client\nimport { createProdMockServer } from 'vite-plugin-mock/client'\nimport roleMock from '../mock/dep/role'\n// functional form\nimport userMockFn from '../mock/user'\n\nexport async function setupProdMockServer() {\n  const mockModules = [...roleMock, ...userMockFn()]\n  createProdMockServer(mockModules)\n}\n```\n\n### Features\n\n- Upgrade all dependencies to latest\n- support `vite4` and `rollup3`\n- The function module supports returning a function\n\n```ts\nimport type { MockConfig } from 'vite-plugin-mock'\n\nexport default (config?: MockConfig) => {\n  return [\n    {\n      url: '/api/createUser',\n      method: 'post',\n      response: ({ body, query }) => {\n        console.log('body>>>>>>>>', body)\n        console.log('query>>>>>>>>', query)\n\n        return {\n          code: 0,\n          message: 'ok',\n          data: { a: 21, 'import.meta.url': import.meta.url },\n        }\n      },\n    },\n  ]\n}\n```\n\n## [2.9.8](https://github.com/vbenjs/vite-plugin-mock/compare/v2.9.0...v2.9.8) (2023-04-17)\n\n### Bug Fixes\n\n- can't update in real time, fix [#40](https://github.com/vbenjs/vite-plugin-mock/issues/40) ([f25c6ac](https://github.com/vbenjs/vite-plugin-mock/commit/f25c6ac8544991457368746bf6ec5fdfd8b4e083))\n- error handle, fix [#39](https://github.com/vbenjs/vite-plugin-mock/issues/39) ([874318c](https://github.com/vbenjs/vite-plugin-mock/commit/874318ce399dc78c33d91161b73e3ced7bb6e9b6))\n- fix js parsing error ([1dbee45](https://github.com/vbenjs/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- fix node version ([#38](https://github.com/vbenjs/vite-plugin-mock/issues/38)) ([f91dea1](https://github.com/vbenjs/vite-plugin-mock/commit/f91dea1be943aa1145727bfecd273ef45cdff8e9))\n- inappropriate type annotation ([#90](https://github.com/vbenjs/vite-plugin-mock/issues/90)) ([a3fc4aa](https://github.com/vbenjs/vite-plugin-mock/commit/a3fc4aab3dd1864f640918516c10d7d1530f5d90))\n- typo, close [#42](https://github.com/vbenjs/vite-plugin-mock/issues/42) ([5b4e946](https://github.com/vbenjs/vite-plugin-mock/commit/5b4e9469060109a2a28c079eec8384fe654be68e))\n\n### Features\n\n- **prod:** response 在 prod 模式下入参对象加上 url ([#83](https://github.com/vbenjs/vite-plugin-mock/issues/83)) ([cd0b86f](https://github.com/vbenjs/vite-plugin-mock/commit/cd0b86fce20228094cf18be14194498a2cbd490e))\n- **server:** add this for response, rawResponse function ([#43](https://github.com/vbenjs/vite-plugin-mock/issues/43)) ([2f4d6d2](https://github.com/vbenjs/vite-plugin-mock/commit/2f4d6d2984c7fe15236cb8b0d2ec5479930d5668))\n\n## [2.9.8](https://github.com/anncwb/vite-plugin-mock/compare/v2.9.0...v2.9.8) (2023-04-16)\n\n### Bug Fixes\n\n- can't update in real time, fix [#40](https://github.com/anncwb/vite-plugin-mock/issues/40) ([f25c6ac](https://github.com/anncwb/vite-plugin-mock/commit/f25c6ac8544991457368746bf6ec5fdfd8b4e083))\n- error handle, fix [#39](https://github.com/anncwb/vite-plugin-mock/issues/39) ([874318c](https://github.com/anncwb/vite-plugin-mock/commit/874318ce399dc78c33d91161b73e3ced7bb6e9b6))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- fix node version ([#38](https://github.com/anncwb/vite-plugin-mock/issues/38)) ([f91dea1](https://github.com/anncwb/vite-plugin-mock/commit/f91dea1be943aa1145727bfecd273ef45cdff8e9))\n- inappropriate type annotation ([#90](https://github.com/anncwb/vite-plugin-mock/issues/90)) ([a3fc4aa](https://github.com/anncwb/vite-plugin-mock/commit/a3fc4aab3dd1864f640918516c10d7d1530f5d90))\n- typo, close [#42](https://github.com/anncwb/vite-plugin-mock/issues/42) ([5b4e946](https://github.com/anncwb/vite-plugin-mock/commit/5b4e9469060109a2a28c079eec8384fe654be68e))\n\n### Features\n\n- **prod:** response 在 prod 模式下入参对象加上 url ([#83](https://github.com/anncwb/vite-plugin-mock/issues/83)) ([cd0b86f](https://github.com/anncwb/vite-plugin-mock/commit/cd0b86fce20228094cf18be14194498a2cbd490e))\n- **server:** add this for response, rawResponse function ([#43](https://github.com/anncwb/vite-plugin-mock/issues/43)) ([2f4d6d2](https://github.com/anncwb/vite-plugin-mock/commit/2f4d6d2984c7fe15236cb8b0d2ec5479930d5668))\n\n## [2.9.6](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.6) (2021-08-23)\n\n### Bug Fixes\n\n- can't update in real time, fix [#40](https://github.com/anncwb/vite-plugin-mock/issues/40) ([f25c6ac](https://github.com/anncwb/vite-plugin-mock/commit/f25c6ac8544991457368746bf6ec5fdfd8b4e083))\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- error handle, fix [#39](https://github.com/anncwb/vite-plugin-mock/issues/39) ([874318c](https://github.com/anncwb/vite-plugin-mock/commit/874318ce399dc78c33d91161b73e3ced7bb6e9b6))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- fix node version ([#38](https://github.com/anncwb/vite-plugin-mock/issues/38)) ([f91dea1](https://github.com/anncwb/vite-plugin-mock/commit/f91dea1be943aa1145727bfecd273ef45cdff8e9))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n- typo, close [#42](https://github.com/anncwb/vite-plugin-mock/issues/42) ([5b4e946](https://github.com/anncwb/vite-plugin-mock/commit/5b4e9469060109a2a28c079eec8384fe654be68e))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n- **server:** add this for response, rawResponse function ([#43](https://github.com/anncwb/vite-plugin-mock/issues/43)) ([2f4d6d2](https://github.com/anncwb/vite-plugin-mock/commit/2f4d6d2984c7fe15236cb8b0d2ec5479930d5668))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.9.5](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.5) (2021-08-23)\n\n### Bug Fixes\n\n- can't update in real time, fix [#40](https://github.com/anncwb/vite-plugin-mock/issues/40) ([f25c6ac](https://github.com/anncwb/vite-plugin-mock/commit/f25c6ac8544991457368746bf6ec5fdfd8b4e083))\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- error handle, fix [#39](https://github.com/anncwb/vite-plugin-mock/issues/39) ([874318c](https://github.com/anncwb/vite-plugin-mock/commit/874318ce399dc78c33d91161b73e3ced7bb6e9b6))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- fix node version ([#38](https://github.com/anncwb/vite-plugin-mock/issues/38)) ([f91dea1](https://github.com/anncwb/vite-plugin-mock/commit/f91dea1be943aa1145727bfecd273ef45cdff8e9))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n- **server:** add this for response, rawResponse function ([#43](https://github.com/anncwb/vite-plugin-mock/issues/43)) ([2f4d6d2](https://github.com/anncwb/vite-plugin-mock/commit/2f4d6d2984c7fe15236cb8b0d2ec5479930d5668))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.9.4](https://github.com/anncwb/vite-plugin-mock/compare/v2.9.0...v2.9.4) (2021-08-01)\n\n### Bug Fixes\n\n- can't update in real time, fix [#40](https://github.com/anncwb/vite-plugin-mock/issues/40) ([f25c6ac](https://github.com/anncwb/vite-plugin-mock/commit/f25c6ac8544991457368746bf6ec5fdfd8b4e083))\n- error handle, fix [#39](https://github.com/anncwb/vite-plugin-mock/issues/39) ([874318c](https://github.com/anncwb/vite-plugin-mock/commit/874318ce399dc78c33d91161b73e3ced7bb6e9b6))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- fix node version ([#38](https://github.com/anncwb/vite-plugin-mock/issues/38)) ([f91dea1](https://github.com/anncwb/vite-plugin-mock/commit/f91dea1be943aa1145727bfecd273ef45cdff8e9))\n\n## [2.9.3](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.3) (2021-07-18)\n\n### Bug Fixes\n\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.9.2](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.2) (2021-07-18)\n\n### Bug Fixes\n\n- ensure file changes take effect,fix [#36](https://github.com/anncwb/vite-plugin-mock/issues/36) ([353aa9d](https://github.com/anncwb/vite-plugin-mock/commit/353aa9db67483072a3d60b6bf3c99736563bba43))\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.9.1](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.1) (2021-07-06)\n\n### Bug Fixes\n\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- fix js parsing error ([d2746b6](https://github.com/anncwb/vite-plugin-mock/commit/d2746b6d788cdd304cac8512afa743b01edbd479))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n# [2.9.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.0) (2021-07-05)\n\n### Bug Fixes\n\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n# [2.8.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.8.0) (2021-06-16)\n\n### Bug Fixes\n\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([bfed256](https://github.com/anncwb/vite-plugin-mock/commit/bfed256bff42e2348b30a6b31746854b18fc90b8))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([a341c7d](https://github.com/anncwb/vite-plugin-mock/commit/a341c7d5b2de153593c0d1f5dab00b1b730a6819))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.7.2](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.7.2) (2021-06-10)\n\n### Bug Fixes\n\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.7.1](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.7.1) (2021-06-09)\n\n### Bug Fixes\n\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n# [2.6.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.6.0) (2021-05-29)\n\n### Bug Fixes\n\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n# [2.5.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.4.0...v2.5.0) (2021-04-06)\n\n### Bug Fixes\n\n- production xhr ([6c94783](https://github.com/anncwb/vite-plugin-mock/commit/6c94783f07b27c6ac58a4642c0e7eddf34b06f1f))\n- **eslint warn:** fix some warn ([b44c13b](https://github.com/anncwb/vite-plugin-mock/commit/b44c13b766cda0ee310071e9febeb48d73ef7bde))\n- empty TS file in mock folder is error ([669b804](https://github.com/anncwb/vite-plugin-mock/commit/669b804df31f537bf6985b56972b32dd11e20504))\n\n### Features\n\n- add rawResponse option to MockMethod ([#17](https://github.com/anncwb/vite-plugin-mock/issues/17)) ([24775f9](https://github.com/anncwb/vite-plugin-mock/commit/24775f9d7b14d024d90cd36c850a00634341927f)), closes [#16](https://github.com/anncwb/vite-plugin-mock/issues/16)\n\n### Performance Improvements\n\n- perf code ([98b9dbc](https://github.com/anncwb/vite-plugin-mock/commit/98b9dbc64f5c6da815a1f29c6b588fddd5189370))\n\n## [2.4.1](https://github.com/anncwb/vite-plugin-mock/compare/v2.4.0...v2.4.1) (2021-03-30)\n\n### Bug Fixes\n\n- empty TS file in mock folder is error ([669b804](https://github.com/anncwb/vite-plugin-mock/commit/669b804df31f537bf6985b56972b32dd11e20504))\n\n### Performance Improvements\n\n- perf code ([98b9dbc](https://github.com/anncwb/vite-plugin-mock/commit/98b9dbc64f5c6da815a1f29c6b588fddd5189370))\n\n# [2.4.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.3.0...v2.4.0) (2021-03-25)\n\n### Features\n\n- response return headers, close [#10](https://github.com/anncwb/vite-plugin-mock/issues/10) ([bcb7abd](https://github.com/anncwb/vite-plugin-mock/commit/bcb7abd98e8726af6f1721ad021c06028b1ffca7))\n\n## [2.2.4](https://github.com/anncwb/vite-plugin-mock/compare/v2.2.3...v2.2.4) (2021-03-10)\n\n### Features\n\n- support post restful close [#7](https://github.com/anncwb/vite-plugin-mock/issues/7) ([70b51e8](https://github.com/anncwb/vite-plugin-mock/commit/70b51e8738e41a7011e38e942dd2a136e450ae9f))\n\n## [2.2.3](https://github.com/anncwb/vite-plugin-mock/compare/v2.2.0...v2.2.3) (2021-03-10)\n\n### Bug Fixes\n\n- ensure that the URLs of different request methods cannot match close [#6](https://github.com/anncwb/vite-plugin-mock/issues/6) ([361a3eb](https://github.com/anncwb/vite-plugin-mock/commit/361a3eb62874f7a6dce8cdc8add4487302c3ee04))\n\n### Features\n\n- support restful api close [#4](https://github.com/anncwb/vite-plugin-mock/issues/4) ([236393e](https://github.com/anncwb/vite-plugin-mock/commit/236393ef551de32fbba62fbb27f678d4782568ec))\n\n## [2.2.1](https://github.com/anncwb/vite-plugin-mock/compare/v2.2.0...v2.2.1) (2021-03-09)\n\n### Features\n\n- support restful api close [#4](https://github.com/anncwb/vite-plugin-mock/issues/4) ([7a35b1a](https://github.com/anncwb/vite-plugin-mock/commit/7a35b1a3af3bfa8623f1d24f53e71928df20b69b))\n\n# [2.2.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.1.5...v2.2.0) (2021-03-02)\n\n### Features\n\n- add logger option ([66a75ab](https://github.com/anncwb/vite-plugin-mock/commit/66a75ab0ee5a7c8e03987e74f15b50aedd1cc29f))\n\n## [2.1.5](https://github.com/anncwb/vite-plugin-mock/compare/v2.0.0-beta.1...v2.1.5) (2021-02-23)\n\n### Bug Fixes\n\n- correct sourcemap ([2140987](https://github.com/anncwb/vite-plugin-mock/commit/21409876876b845b18b5b006e98292138870a922))\n- dev sourcemap ([5834b4f](https://github.com/anncwb/vite-plugin-mock/commit/5834b4f621b25371a7b0246a48fb83b9761afeed))\n- fix post proxy error ([d3ae41e](https://github.com/anncwb/vite-plugin-mock/commit/d3ae41e18a5e7adae504457165ba7b34b8ebff6f))\n\n### Features\n\n- support sourcemap ([8c3cd9d](https://github.com/anncwb/vite-plugin-mock/commit/8c3cd9d78a9bd7f87dc7900e9bfe6c753ff3b11f))\n\n### Performance Improvements\n\n- imporve request log ([f9353fd](https://github.com/anncwb/vite-plugin-mock/commit/f9353fdf8149665f984729ab3c7a6749022cfdaf))\n\n# [2.0.0-beta.1](https://github.com/anncwb/vite-plugin-mock/compare/2.0.0-beta.1...v2.0.0-beta.1) (2021-01-03)\n\n### Bug Fixes\n\n- Fix local development post request proxy to https ([7965604](https://github.com/anncwb/vite-plugin-mock/commit/79656046377f501da796d1be9752522a2203d69b))\n- remove unnecessary and wrong usage of \"try catch\" ([815abde](https://github.com/anncwb/vite-plugin-mock/commit/815abde26f8f9a19322916ae01a9896a9aced33a))\n\n### Features\n\n- add request time ([ccbb14a](https://github.com/anncwb/vite-plugin-mock/commit/ccbb14ad623e6549781e5e902819f830a291f13f))\n\n## [1.0.2](https://github.com/anncwb/vite-plugin-mock/compare/1.0.1...1.0.2) (2020-09-14)\n\n### Features\n\n- add examples ([2c5a86b](https://github.com/anncwb/vite-plugin-mock/commit/2c5a86bb75e39b6c7c9e08b1691c0541aeb104d9))\n\n## [1.0.1](https://github.com/anncwb/vite-plugin-mock/compare/58ad7cd57e3fd0daa92e0fc59c00e09cf6ba45ad...1.0.1) (2020-09-14)\n\n### Features\n\n- add supportTs options,Support es6 and commonjs modules in .js folder ([37f83f5](https://github.com/anncwb/vite-plugin-mock/commit/37f83f54c3a34e049f967b0db0ac2ade401cbf58))\n\n### Performance Improvements\n\n- Replace typescript plug-in with a faster esbuild plug-in ([58ad7cd](https://github.com/anncwb/vite-plugin-mock/commit/58ad7cd57e3fd0daa92e0fc59c00e09cf6ba45ad))\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2020-present, Vben\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "# vite-plugin-mock\n\n**English** | [中文](./README.zh_CN.md)\n\n[![npm][npm-img]][npm-url] [![node][node-img]][node-url]\n\nProvide local and prod mocks for vite.\n\nA mock plugin for vite, developed based on mockjs. And support the local environment and production environment at the same time. Connect service middleware is used locally, mockjs is used online\n\n### Install (yarn or npm)\n\n**node version:** >=12.0.0\n\n**vite version:** >=2.0.0\n\n```bash\nyarn add mockjs\n# or\nnpm i  mockjs -S\n# or\npnpm add mockjs\n```\n\nand\n\n```bash\nyarn add vite-plugin-mock -D\n# or\nnpm i vite-plugin-mock -D\n# or\npnpm add vite-plugin-mock -D\n```\n\n### Example\n\n**Run Example**\n\n```bash\n\n# ts example\ncd ./examples/ts-examples\n\nyarn install\n\nyarn serve\n\n# js example\n\ncd ./examples/js-examples\n\nyarn install\n\nyarn serve\n```\n\n## Usage\n\n**Development environment**\n\nThe development environment is implemented using Connect middleware。\n\nDifferent from the production environment, you can view the network request record in the Google Chrome console\n\n- Config plugin in vite.config.ts\n\n```ts\nimport { UserConfigExport, ConfigEnv } from 'vite'\n\nimport { viteMockServe } from 'vite-plugin-mock'\nimport vue from '@vitejs/plugin-vue'\n\nexport default ({ command }: ConfigEnv): UserConfigExport => {\n  return {\n    plugins: [\n      vue(),\n      viteMockServe({\n        // default\n        mockPath: 'mock',\n        enable: true,\n      }),\n    ],\n  }\n}\n```\n\n- viteMockServe Options\n\n```ts\n{\n    mockPath?: string;\n    ignore?: RegExp | ((fileName: string) => boolean);\n    watchFiles?: boolean;\n    enable?: boolean;\n    ignoreFiles?: string[];\n    configPath?: string;\n}\n```\n\n## Options\n\n### mockPath\n\n**type:** `string`\n\n**default:** `'mock'`\n\nSet the folder where the mock .ts file is stored\n\nIf `watchFiles:true`, the file changes in the folder will be monitored. And synchronize to the request result in real time\n\nIf configPath has a value, it is invalid\n\n### ignore\n\n**type:** `RegExp | ((fileName: string) => boolean);`\n\n**default:** `undefined`\n\nWhen automatically reading analog .ts files, ignore files in the specified format\n\n### watchFiles\n\n**type:** `boolean`\n\n**default:** `true`\n\nSet whether to monitor changes in mock .ts files\n\n### enable\n\n**type:** `boolean`\n\n**default:** true\n\nWhether to enable the mock function\n\n### configPath\n\n**type:** `string`\n\n**default:** `vite.mock.config.ts`\n\nSet the data entry that the mock reads. When the file exists and is located in the project root directory, the file will be read and used first. The configuration file returns an array\n\n### logger\n\n**type:** `boolean`\n\n**default:** `true`\n\nWhether to display the request log on the console\n\n## Mock file example\n\n`/path/mock`\n\n```ts\n// test.ts\n\nimport { MockMethod, MockConfig } from 'vite-plugin-mock'\nexport default [\n  {\n    url: '/api/get',\n    method: 'get',\n    response: ({ query }) => {\n      return {\n        code: 0,\n        data: {\n          name: 'vben',\n        },\n      }\n    },\n  },\n  {\n    url: '/api/post',\n    method: 'post',\n    timeout: 2000,\n    response: {\n      code: 0,\n      data: {\n        name: 'vben',\n      },\n    },\n  },\n  {\n    url: '/api/text',\n    method: 'post',\n    rawResponse: async (req, res) => {\n      let reqbody = ''\n      await new Promise((resolve) => {\n        req.on('data', (chunk) => {\n          reqbody += chunk\n        })\n        req.on('end', () => resolve(undefined))\n      })\n      res.setHeader('Content-Type', 'text/plain')\n      res.statusCode = 200\n      res.end(`hello, ${reqbody}`)\n    },\n  },\n] as MockMethod[]\n\nexport default function (config: MockConfig) {\n  return [\n    {\n      url: '/api/text',\n      method: 'post',\n      rawResponse: async (req, res) => {\n        let reqbody = ''\n        await new Promise((resolve) => {\n          req.on('data', (chunk) => {\n            reqbody += chunk\n          })\n          req.on('end', () => resolve(undefined))\n        })\n        res.setHeader('Content-Type', 'text/plain')\n        res.statusCode = 200\n        res.end(`hello, ${reqbody}`)\n      },\n    },\n  ]\n}\n```\n\n### MockMethod\n\n```ts\n{\n  // request url\n  url: string;\n  // request method\n  method?: MethodType;\n  // Request time in milliseconds\n  timeout?: number;\n  // default: 200\n  statusCode?:number;\n  // response data (JSON)\n  response?: ((opt: { [key: string]: string; body: Record<string,any>; query:  Record<string,any>, headers: Record<string, any>; }) => any) | any;\n  // response (non-JSON)\n  rawResponse?: (req: IncomingMessage, res: ServerResponse) => void;\n}\n\n```\n\n### Example (3.0.0 recommended)\n\nCreate the `mockProdServer.ts` file\n\n```ts\n//  mockProdServer.ts\n\nimport { createProdMockServer } from 'vite-plugin-mock/client'\n\n// Import your mock .ts files one by one\n// If you use vite.mock.config.ts, just import the file directly\n// You can use the import.meta.glob function to import all\nimport testModule from '../mock/test'\n\nexport function setupProdMockServer() {\n  createProdMockServer([...testModule])\n}\n```\n\nConfig `vite-plugin-mock`\n\n```ts\nimport { viteMockServe } from 'vite-plugin-mock'\n\nimport { UserConfigExport, ConfigEnv } from 'vite'\n\nexport default ({ command }: ConfigEnv): UserConfigExport => {\n  return {\n    plugins: [\n      viteMockServe({\n        mockPath: 'mock',\n        // According to the project configuration. Can be configured in the .env file\n        enable: true,\n      }),\n    ],\n  }\n}\n```\n\n## Sample project\n\n[Vben Admin](https://github.com/anncwb/vue-vben-admin)\n\n## Note\n\n- The node module cannot be used in the mock .ts file, otherwise the production environment will fail\n- Mock is used in the production environment, which is only suitable for some test environments. Do not open it in the formal environment to avoid unnecessary errors. At the same time, in the production environment, it may affect normal Ajax requests, such as file upload failure, etc.\n\n## License\n\nMIT\n\n[npm-img]: https://img.shields.io/npm/v/vite-plugin-mock.svg\n[npm-url]: https://npmjs.com/package/vite-plugin-mock\n[node-img]: https://img.shields.io/node/v/vite-plugin-mock.svg\n[node-url]: https://nodejs.org/en/about/releases/\n"
  },
  {
    "path": "README.zh_CN.md",
    "content": "# vite-plugin-mock\n\n**中文** | [English](./README.md)\n\n[![npm][npm-img]][npm-url] [![node][node-img]][node-url]\n\n提供本地和生产模拟服务。\n\nvite 的数据模拟插件，是基于 vite.js 开发的。 并同时支持本地环境和生产环境。 Connect 服务中间件在本地使用，mockjs 在生产环境中使用。\n\n## Production environment problem description\n\nThe current production environment cannot support the acquisition of `headers` and the acquisition of `restful`Url format parameters. So there are those two formats that need to be used in the production environment.\n\n### 安装 (yarn or npm)\n\n**node version:** >=12.0.0\n\n**vite version:** >=2.0.0\n\n```bash\nyarn add mockjs\n# or\nnpm i  mockjs -S\n# or\npnpm add mockjs\n```\n\nand\n\n```bash\nyarn add vite-plugin-mock -D\n# or\nnpm i vite-plugin-mock -D\n# or\npnpm add vite-plugin-mock -D\n```\n\n## 使用\n\n**开发环境**\n\n开发环境是使用 Connect 中间件实现的。\n\n与生产环境不同，您可以在 Google Chrome 控制台中查看网络请求记录\n\n- vite.config.ts 配置\n\n```ts\nimport { UserConfigExport, ConfigEnv } from 'vite'\n\nimport { viteMockServe } from 'vite-plugin-mock'\nimport vue from '@vitejs/plugin-vue'\n\nexport default ({ command }: ConfigEnv): UserConfigExport => {\n  return {\n    plugins: [\n      vue(),\n      viteMockServe({\n        mockPath: 'mock',\n        enable: true,\n      }),\n    ],\n  }\n}\n```\n\n- viteMockServe 配置\n\n```ts\n{\n    mockPath?: string;\n    ignore?: RegExp | ((fileName: string) => boolean);\n    watchFiles?: boolean;\n    enable?: boolean;\n    ignoreFiles?: string[];\n    configPath?: string;\n    logger?:boolean;\n}\n```\n\n### mockPath\n\n**type:** string\n\n**default:** `mock`\n\n设置模拟.ts 文件的存储文件夹\n\n如果`watchFiles：true`，将监视文件夹中的文件更改。 并实时同步到请求结果\n\n如果 `configPath` 具有值，则无效\n\n### ignore\n\n**type:** `RegExp | ((fileName: string) => boolean)`;\n\n**default:** `undefined`\n\n自动读取模拟.ts 文件时，请忽略指定格式的文件\n\n### watchFiles\n\n**type:** `boolean`\n\n**default:** `true`\n\n设置是否监视`mockPath`对应的文件夹内文件中的更改\n\n### enable\n\n**type:** `boolean`\n\n**default:** true\n\n是否启用 mock 功能\n\n### configPath\n\n**type:** `string`\n\n**default:** `vite.mock.config.ts`\n\n设置模拟读取的数据条目。 当文件存在并且位于项目根目录中时，将首先读取并使用该文件。 配置文件返回一个数组\n\n### logger\n\n**type:** `boolean`\n\n**default:** `true`\n\n是否在控制台显示请求日志\n\n## Mock file example\n\n`/path/mock`\n\n```ts\n// test.ts\n\nimport { MockMethod, MockConfig } from 'vite-plugin-mock'\nexport default [\n  {\n    url: '/api/get',\n    method: 'get',\n    response: ({ query }) => {\n      return {\n        code: 0,\n        data: {\n          name: 'vben',\n        },\n      }\n    },\n  },\n  {\n    url: '/api/post',\n    method: 'post',\n    timeout: 2000,\n    response: {\n      code: 0,\n      data: {\n        name: 'vben',\n      },\n    },\n  },\n  {\n    url: '/api/text',\n    method: 'post',\n    rawResponse: async (req, res) => {\n      let reqbody = ''\n      await new Promise((resolve) => {\n        req.on('data', (chunk) => {\n          reqbody += chunk\n        })\n        req.on('end', () => resolve(undefined))\n      })\n      res.setHeader('Content-Type', 'text/plain')\n      res.statusCode = 200\n      res.end(`hello, ${reqbody}`)\n    },\n  },\n] as MockMethod[]\n\nexport default function (config: MockConfig) {\n  return [\n    {\n      url: '/api/text',\n      method: 'post',\n      rawResponse: async (req, res) => {\n        let reqbody = ''\n        await new Promise((resolve) => {\n          req.on('data', (chunk) => {\n            reqbody += chunk\n          })\n          req.on('end', () => resolve(undefined))\n        })\n        res.setHeader('Content-Type', 'text/plain')\n        res.statusCode = 200\n        res.end(`hello, ${reqbody}`)\n      },\n    },\n  ]\n}\n```\n\n### MockMethod\n\n```ts\n{\n  // 请求地址\n  url: string;\n  // 请求方式\n  method?: MethodType;\n  // 设置超时时间\n  timeout?: number;\n  // 状态吗\n  statusCode?:number;\n  // 响应数据（JSON）\n  response?: ((opt: { [key: string]: string; body: Record<string,any>; query:  Record<string,any>, headers: Record<string, any>; }) => any) | any;\n  // 响应（非JSON）\n  rawResponse?: (req: IncomingMessage, res: ServerResponse) => void;\n}\n\n```\n\n## 在生产环境中的使用\n\n创建`mockProdServer.ts` 文件\n\n```ts\n//  mockProdServer.ts\nimport { createProdMockServer } from 'vite-plugin-mock/client'\n\n// 逐一导入您的mock.ts文件\n// 如果使用vite.mock.config.ts，只需直接导入文件\n// 可以使用 import.meta.glob功能来进行全部导入\nimport testModule from '../mock/test'\n\nexport function setupProdMockServer() {\n  createProdMockServer([...testModule])\n}\n```\n\n配置 `vite-plugin-mock`\n\n```ts\nimport { viteMockServe } from 'vite-plugin-mock'\n\nimport { UserConfigExport, ConfigEnv } from 'vite'\n\nexport default ({ command }: ConfigEnv): UserConfigExport => {\n  return {\n    plugins: [\n      viteMockServe({\n        mockPath: 'mock',\n        // 根据项目配置。可以配置在.env文件\n        enable: true,\n      }),\n    ],\n  }\n}\n```\n\n### 示例\n\n**运行示例**\n\n```bash\npnpm install\n\n# ts example\ncd ./examples/ts-examples\n\npnpm run serve\n\n# js example\n\ncd ./examples/js-examples\n\npnpm run serve\n```\n\n## 示例项目\n\n[Vben Admin](https://github.com/anncwb/vue-vben-admin)\n\n## 注意事项\n\n- 无法在 mock.ts 文件中使用 node 模块，否则生产环境将失败\n- 模拟数据如果用于生产环境，仅适用于某些测试环境。 不要在正式环境中打开它，以避免不必要的错误。 同时，在生产环境中，它可能会影响正常的 Ajax 请求，例如文件上传/下载失败等。\n\n## License\n\nMIT\n\n[npm-img]: https://img.shields.io/npm/v/vite-plugin-mock.svg\n[npm-url]: https://npmjs.com/package/vite-plugin-mock\n[node-img]: https://img.shields.io/node/v/vite-plugin-mock.svg\n[node-url]: https://nodejs.org/en/about/releases/\n"
  },
  {
    "path": "commitlint.config.js",
    "content": "module.exports = { extends: ['@commitlint/config-conventional'] }\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"vite-plugin-mock-monorepo\",\n  \"version\": \"2.9.8\",\n  \"private\": true,\n  \"description\": \"A mock plugin for vite\",\n  \"files\": [\n    \"dist\",\n    \"es\"\n  ],\n  \"engines\": {\n    \"node\": \">=12.0.0\"\n  },\n  \"scripts\": {\n    \"log\": \"conventional-changelog -p angular -i CHANGELOG.md -s\",\n    \"lint:lint-staged\": \"lint-staged -c ./.husky/lintstagedrc.js\",\n    \"lint:eslint\": \"eslint \\\"src/**/*.{ts,tsx}\\\" --fix\",\n    \"prepare\": \"husky install\"\n  },\n  \"keywords\": [\n    \"vite\",\n    \"mock\",\n    \"hmr\"\n  ],\n  \"author\": \"Vben\",\n  \"license\": \"MIT\",\n  \"devDependencies\": {\n    \"@commitlint/cli\": \"^17.6.1\",\n    \"@commitlint/config-conventional\": \"^17.6.1\",\n    \"@types/connect\": \"^3.4.35\",\n    \"@types/debug\": \"^4.1.7\",\n    \"@types/node\": \"^16.18.23\",\n    \"@typescript-eslint/eslint-plugin\": \"^5.58.0\",\n    \"@typescript-eslint/parser\": \"^5.58.0\",\n    \"commitizen\": \"^4.3.0\",\n    \"conventional-changelog-cli\": \"^2.2.2\",\n    \"eslint\": \"^8.38.0\",\n    \"eslint-config-prettier\": \"^8.8.0\",\n    \"husky\": \"^8.0.3\",\n    \"lint-staged\": \"^13.2.1\",\n    \"prettier\": \"^2.8.7\",\n    \"rimraf\": \"^5.0.0\",\n    \"typescript\": \"^5.0.4\"\n  }\n}\n"
  },
  {
    "path": "packages/playground/js-example/.gitignore",
    "content": "node_modules\n.DS_Store\ndist\n*.local"
  },
  {
    "path": "packages/playground/js-example/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <link rel=\"icon\" href=\"/favicon.ico\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>Vite App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n    <script type=\"module\" src=\"/src/main.js\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "packages/playground/js-example/mock/role.mjs",
    "content": "export default [\n  {\n    url: '/api/getRoleById',\n    method: 'get',\n    response: ({ query }) => {\n      console.log('id>>>>>>>>', query.id)\n      return {\n        code: 0,\n        message: 'ok',\n        data: {\n          roleName: 'admin',\n          roleValue: 'admin1',\n        },\n      }\n    },\n  },\n]\n"
  },
  {
    "path": "packages/playground/js-example/mock/user.js",
    "content": "export default [\n  {\n    url: '/api/createUser',\n    method: 'post',\n    response: ({ body }) => {\n      console.log('body>>>>>>>>', body)\n      return {\n        code: 0,\n        message: 'ok',\n        data: null,\n      }\n    },\n  },\n]\n"
  },
  {
    "path": "packages/playground/js-example/package.json",
    "content": "{\n  \"name\": \"ts-example\",\n  \"version\": \"0.0.0\",\n  \"private\": true,\n  \"scripts\": {\n    \"dev\": \"cross-env NODE_ENV=development vite\",\n    \"build\": \"cross-env NODE_ENV=production vite build \"\n  },\n  \"dependencies\": {\n    \"axios\": \"^1.3.5\",\n    \"element-plus\": \"^2.3.3\",\n    \"mockjs\": \"^1.1.0\",\n    \"vue\": \"^3.2.47\"\n  },\n  \"devDependencies\": {\n    \"@vitejs/plugin-vue\": \"^4.1.0\",\n    \"@vue/compiler-sfc\": \"^3.2.47\",\n    \"cross-env\": \"^7.0.3\",\n    \"vite\": \"^4.2.1\",\n    \"vite-plugin-mock\": \"workspace:*\"\n  }\n}\n"
  },
  {
    "path": "packages/playground/js-example/src/App.vue",
    "content": "<template>\n  <div class=\"container\">\n    <h1>\n      <el-link\n        type=\"success\"\n        href=\"https://github.com/anncwb/vite-plugin-mock/tree/main/examples/js-example\"\n        target=\"_blank\"\n        class=\"_link\"\n        >测试vite-plugin-mock（JS版本）</el-link\n      >\n    </h1>\n    <el-space wrap>\n      <el-card class=\"box-card\" v-for=\"(item, key) in requestLists\" :key=\"key\">\n        <template #header>\n          <div class=\"card-header\">\n            <span>{{ item.name }}</span>\n            <el-button\n              class=\"button\"\n              size=\"mini\"\n              type=\"primary\"\n              plain\n              @click=\"sendRequest(key, item)\"\n              >Send</el-button\n            >\n          </div>\n        </template>\n        <div v-loading=\"item.show\">{{ item.info }}</div>\n      </el-card>\n    </el-space>\n  </div>\n</template>\n\n<script>\nimport { defineComponent, ref } from 'vue'\nimport axios from 'axios'\nexport default defineComponent({\n  name: 'App',\n  setup() {\n    const requestLists = ref([\n      {\n        name: 'Get Request',\n        info: '暂无数据',\n        show: false,\n      },\n      {\n        name: 'Post Request',\n        info: '暂无数据',\n        show: false,\n      },\n    ])\n\n    const getRoleById = () => {\n      requestLists.value[0].show = true\n      axios.get('/api/getRoleById', { params: { id: 1 } }).then(({ data }) => {\n        requestLists.value[0].info = data\n        requestLists.value[0].show = false\n      })\n    }\n\n    const createUser = () => {\n      requestLists.value[1].show = true\n      axios\n        .post('/api/createUser', {\n          name: 'vben',\n          gender: 'man',\n        })\n        .then(({ data }) => {\n          requestLists.value[1].info = data\n          requestLists.value[1].show = false\n        })\n    }\n\n    const sendRequest = (key, item) => {\n      key === 0 ? getRoleById() : createUser()\n    }\n\n    return {\n      requestLists,\n      sendRequest,\n    }\n  },\n})\n</script>\n\n<style scoped>\n.card-header {\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n}\n._link {\n  font-size: 30px;\n}\n.box-card {\n  width: 360px;\n}\n.el-space {\n  align-items: flex-start !important;\n}\n</style>\n"
  },
  {
    "path": "packages/playground/js-example/src/main.js",
    "content": "import { createApp } from 'vue'\nimport App from './App.vue'\n\nimport ElementPlus from 'element-plus'\nimport 'element-plus/theme-chalk/index.css'\n\ncreateApp(App).use(ElementPlus).mount('#app')\n"
  },
  {
    "path": "packages/playground/js-example/src/mockProdServer.js",
    "content": "import { createProdMockServer } from '../../../es/createProdMockServer'\nimport roleMock from '../mock/role'\nimport userMock from '../mock/user'\n\nexport function setupProdMockServer() {\n  createProdMockServer([...roleMock, ...userMock])\n}\n"
  },
  {
    "path": "packages/playground/js-example/vite.config.js",
    "content": "import { viteMockServe } from 'vite-plugin-mock'\n\nimport vue from '@vitejs/plugin-vue'\n\nexport default ({ command }) => {\n  let prodMock = true\n  return {\n    plugins: [\n      vue(),\n      viteMockServe({\n        mockPath: 'mock',\n        enable: true,\n      }),\n    ],\n  }\n}\n"
  },
  {
    "path": "packages/playground/ts-example/.gitignore",
    "content": "node_modules\n.DS_Store\ndist\n*.local\n"
  },
  {
    "path": "packages/playground/ts-example/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"UTF-8\" />\n    <link rel=\"icon\" href=\"/favicon.ico\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n    <title>Vite App</title>\n  </head>\n  <body>\n    <div id=\"app\"></div>\n    <script type=\"module\" src=\"/src/main.ts\"></script>\n  </body>\n</html>\n"
  },
  {
    "path": "packages/playground/ts-example/mock/define.ts",
    "content": "import type { MockConfig } from 'vite-plugin-mock'\n\nexport default (config: MockConfig) => {\n  return [\n    {\n      url: '/api/testRestful/:id',\n      method: 'post',\n      response: ({ query, body }) => {\n        console.log('query>>>>>>>>', query)\n        console.log('body>>>>>>>>', body)\n        return {\n          code: 0,\n          message: 'ok',\n          data: {\n            roleName: 'admin',\n            roleValue: 'admin',\n          },\n        }\n      },\n    },\n  ]\n}\n"
  },
  {
    "path": "packages/playground/ts-example/mock/dep/role.ts",
    "content": "import type { MockMethod } from 'vite-plugin-mock'\nexport default [\n  {\n    url: '/api/getRoleById',\n    method: 'get',\n    response: ({ query }) => {\n      console.log('id>>>>>>>>', query.id)\n      return {\n        code: 0,\n        message: 'ok',\n        data: {\n          roleName: 'admin',\n          roleValue: 'admin',\n        },\n      }\n    },\n  },\n  {\n    url: '/api/testRestful/:id',\n    method: 'get',\n    response: ({ query }) => {\n      console.log('id>>>>>>>>', query.id)\n      return {\n        code: 0,\n        message: 'ok',\n        data: {\n          roleName: 'admin',\n          roleValue: 'admin',\n        },\n      }\n    },\n  },\n] as MockMethod[]\n"
  },
  {
    "path": "packages/playground/ts-example/mock/user.ts",
    "content": "import type { MockConfig } from 'vite-plugin-mock'\n\nexport default (config?: MockConfig) => {\n  return [\n    {\n      url: '/api/createUser',\n      method: 'post',\n      response: ({ body, query }) => {\n        console.log('body>>>>>>>>', body)\n        console.log('query>>>>>>>>', query)\n\n        return {\n          code: 0,\n          message: 'ok',\n          data: { a: 21, 'import.meta.url': import.meta.url },\n        }\n      },\n    },\n  ]\n}\n"
  },
  {
    "path": "packages/playground/ts-example/package.json",
    "content": "{\n  \"name\": \"ts-example\",\n  \"version\": \"0.0.0\",\n  \"private\": true,\n  \"scripts\": {\n    \"dev\": \"cross-env NODE_ENV=development vite\",\n    \"build\": \"cross-env NODE_ENV=production vite build \"\n  },\n  \"dependencies\": {\n    \"axios\": \"^1.3.5\",\n    \"element-plus\": \"^2.3.3\",\n    \"find-up\": \"^6.3.0\",\n    \"mockjs\": \"^1.1.0\",\n    \"vue\": \"^3.2.47\"\n  },\n  \"devDependencies\": {\n    \"@vitejs/plugin-vue\": \"^4.1.0\",\n    \"@vue/compiler-sfc\": \"^3.2.47\",\n    \"cross-env\": \"^7.0.3\",\n    \"typescript\": \"^5.0.4\",\n    \"vite\": \"^4.2.1\",\n    \"vite-plugin-mock\": \"workspace:*\"\n  }\n}\n"
  },
  {
    "path": "packages/playground/ts-example/shim-vue.ts",
    "content": "declare module '*.vue' {\n  import { ComponentOptions } from 'vue'\n  const component: ComponentOptions\n  export default component\n}\n"
  },
  {
    "path": "packages/playground/ts-example/src/App.vue",
    "content": "<template>\n  <div class=\"container\">\n    <h1>\n      <el-link\n        type=\"success\"\n        href=\"https://github.com/anncwb/vite-plugin-mock/tree/main/examples/ts-example\"\n        target=\"_blank\"\n        class=\"_link\"\n        >测试vite-plugin-mock（TS版本）</el-link\n      >\n    </h1>\n    <el-space wrap>\n      <el-card class=\"box-card\" v-for=\"(item, key) in requestLists\" :key=\"key\">\n        <template #header>\n          <div class=\"card-header\">\n            <span>{{ item.name }}</span>\n            <el-button\n              class=\"button\"\n              size=\"mini\"\n              type=\"primary\"\n              plain\n              @click=\"sendRequest(key, item)\"\n              >Send</el-button\n            >\n          </div>\n        </template>\n        <div v-loading=\"item.show\">{{ item.info }}</div>\n      </el-card>\n    </el-space>\n  </div>\n</template>\n\n<script>\nimport { defineComponent, ref } from 'vue'\nimport axios from 'axios'\nexport default defineComponent({\n  name: 'App',\n  setup() {\n    const requestLists = ref([\n      {\n        name: 'Get Request',\n        info: '暂无数据',\n        show: false,\n      },\n      {\n        name: 'Get Restful',\n        info: '暂无数据',\n        show: false,\n      },\n      {\n        name: 'Post Request',\n        info: '暂无数据',\n        show: false,\n      },\n      {\n        name: 'Post Restful',\n        info: '暂无数据',\n        show: false,\n      },\n      {\n        name: 'Post Form-data',\n        info: '暂无数据',\n        show: false,\n      },\n    ])\n\n    const getRoleById = () => {\n      requestLists.value[0].show = true\n      axios.get('/api/getRoleById', { params: { id: 2 } }).then(({ data }) => {\n        requestLists.value[0].info = data\n        requestLists.value[0].show = false\n      })\n    }\n\n    const testRestful = () => {\n      requestLists.value[1].show = true\n      axios.get('/api/testRestful/1').then(({ data }) => {\n        requestLists.value[1].info = data\n        requestLists.value[1].show = false\n      })\n    }\n\n    const createUser = () => {\n      requestLists.value[2].show = true\n      axios\n        .post('/api/createUser', {\n          name: 'vben',\n          gender: 'man',\n        })\n        .then(({ data }) => {\n          requestLists.value[2].info = data\n          requestLists.value[2].show = false\n        })\n    }\n\n    const testPostRestful = () => {\n      requestLists.value[3].show = true\n      axios.post('/api/testRestful/1').then(({ data }) => {\n        requestLists.value[3].info = data\n        requestLists.value[3].show = false\n      })\n    }\n\n    const testPostFormData = () => {\n      requestLists.value[4].show = true\n      axios\n        .post(\n          '/api/createUser?a=1',\n          {\n            name: 'vben',\n            gender: 'man',\n          },\n          { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } },\n        )\n        .then(({ data }) => {\n          requestLists.value[4].info = data\n          requestLists.value[4].show = false\n        })\n    }\n\n    const sendRequest = (key, item) => {\n      switch (key) {\n        case 0:\n          getRoleById()\n          break\n        case 1:\n          testRestful()\n          break\n        case 2:\n          createUser()\n          break\n        case 3:\n          testPostRestful()\n          break\n        case 4:\n          testPostFormData()\n          break\n        default:\n          getRoleById()\n      }\n    }\n\n    return {\n      requestLists,\n      sendRequest,\n    }\n  },\n})\n</script>\n\n<style scoped>\n.card-header {\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n}\n._link {\n  font-size: 30px;\n}\n.box-card {\n  width: 360px;\n}\n.el-space {\n  align-items: flex-start !important;\n}\n</style>\n"
  },
  {
    "path": "packages/playground/ts-example/src/main.ts",
    "content": "import { createApp } from 'vue'\nimport App from './App.vue'\n\nimport ElementPlus from 'element-plus'\nimport 'element-plus/theme-chalk/index.css'\n\ncreateApp(App).use(ElementPlus).mount('#app')\n\n// production mock server\nif (process.env.NODE_ENV === 'production') {\n  import('./mockProdServer').then(({ setupProdMockServer }) => {\n    setupProdMockServer()\n  })\n}\n"
  },
  {
    "path": "packages/playground/ts-example/src/mockProdServer.ts",
    "content": "import { createProdMockServer } from 'vite-plugin-mock/client'\nimport roleMock from '../mock/dep/role'\nimport userMockFn from '../mock/user'\n\nexport async function setupProdMockServer() {\n  const mockModules = [...roleMock, ...userMockFn()]\n  createProdMockServer(mockModules)\n}\n"
  },
  {
    "path": "packages/playground/ts-example/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"esnext\",\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"strict\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"allowSyntheticDefaultImports\": true,\n    \"strictFunctionTypes\": false,\n    \"jsx\": \"preserve\",\n    \"baseUrl\": \".\",\n    \"allowJs\": true,\n    \"sourceMap\": true,\n    \"esModuleInterop\": true,\n    \"resolveJsonModule\": true,\n    \"noUnusedLocals\": true,\n    \"noUnusedParameters\": true,\n    \"experimentalDecorators\": true,\n    \"lib\": [\"dom\", \"esnext\"],\n    \"types\": [\"vite/client\"],\n    \"typeRoots\": [\"./node_modules/@types/\", \"./types\"],\n    \"incremental\": true,\n    \"noImplicitAny\": false,\n    \"skipLibCheck\": true\n  },\n  \"include\": [\"src/**/*.ts\", \"src/**/*.d.ts\", \"src/**/*.tsx\", \"src/**/*.vue\"],\n  \"exclude\": [\"node_modules\", \"dist\", \"**/*.js\"]\n}\n"
  },
  {
    "path": "packages/playground/ts-example/vite.config.ts",
    "content": "import { viteMockServe } from 'vite-plugin-mock'\n\nimport { UserConfigExport } from 'vite'\nimport vue from '@vitejs/plugin-vue'\n\nexport default (): UserConfigExport => {\n  return {\n    plugins: [\n      vue(),\n      viteMockServe({\n        mockPath: 'mock',\n        enable: true,\n        logger: true,\n      }),\n    ],\n  }\n}\n"
  },
  {
    "path": "packages/vite-plugin-mock/CHANGELOG.md",
    "content": "## [2.9.8](https://github.com/anncwb/vite-plugin-mock/compare/v2.9.0...v2.9.8) (2023-04-16)\n\n### Bug Fixes\n\n- can't update in real time, fix [#40](https://github.com/anncwb/vite-plugin-mock/issues/40) ([f25c6ac](https://github.com/anncwb/vite-plugin-mock/commit/f25c6ac8544991457368746bf6ec5fdfd8b4e083))\n- error handle, fix [#39](https://github.com/anncwb/vite-plugin-mock/issues/39) ([874318c](https://github.com/anncwb/vite-plugin-mock/commit/874318ce399dc78c33d91161b73e3ced7bb6e9b6))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- fix node version ([#38](https://github.com/anncwb/vite-plugin-mock/issues/38)) ([f91dea1](https://github.com/anncwb/vite-plugin-mock/commit/f91dea1be943aa1145727bfecd273ef45cdff8e9))\n- inappropriate type annotation ([#90](https://github.com/anncwb/vite-plugin-mock/issues/90)) ([a3fc4aa](https://github.com/anncwb/vite-plugin-mock/commit/a3fc4aab3dd1864f640918516c10d7d1530f5d90))\n- typo, close [#42](https://github.com/anncwb/vite-plugin-mock/issues/42) ([5b4e946](https://github.com/anncwb/vite-plugin-mock/commit/5b4e9469060109a2a28c079eec8384fe654be68e))\n\n### Features\n\n- **prod:** response 在 prod 模式下入参对象加上 url ([#83](https://github.com/anncwb/vite-plugin-mock/issues/83)) ([cd0b86f](https://github.com/anncwb/vite-plugin-mock/commit/cd0b86fce20228094cf18be14194498a2cbd490e))\n- **server:** add this for response, rawResponse function ([#43](https://github.com/anncwb/vite-plugin-mock/issues/43)) ([2f4d6d2](https://github.com/anncwb/vite-plugin-mock/commit/2f4d6d2984c7fe15236cb8b0d2ec5479930d5668))\n\n## [2.9.6](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.6) (2021-08-23)\n\n### Bug Fixes\n\n- can't update in real time, fix [#40](https://github.com/anncwb/vite-plugin-mock/issues/40) ([f25c6ac](https://github.com/anncwb/vite-plugin-mock/commit/f25c6ac8544991457368746bf6ec5fdfd8b4e083))\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- error handle, fix [#39](https://github.com/anncwb/vite-plugin-mock/issues/39) ([874318c](https://github.com/anncwb/vite-plugin-mock/commit/874318ce399dc78c33d91161b73e3ced7bb6e9b6))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- fix node version ([#38](https://github.com/anncwb/vite-plugin-mock/issues/38)) ([f91dea1](https://github.com/anncwb/vite-plugin-mock/commit/f91dea1be943aa1145727bfecd273ef45cdff8e9))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n- typo, close [#42](https://github.com/anncwb/vite-plugin-mock/issues/42) ([5b4e946](https://github.com/anncwb/vite-plugin-mock/commit/5b4e9469060109a2a28c079eec8384fe654be68e))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n- **server:** add this for response, rawResponse function ([#43](https://github.com/anncwb/vite-plugin-mock/issues/43)) ([2f4d6d2](https://github.com/anncwb/vite-plugin-mock/commit/2f4d6d2984c7fe15236cb8b0d2ec5479930d5668))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.9.5](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.5) (2021-08-23)\n\n### Bug Fixes\n\n- can't update in real time, fix [#40](https://github.com/anncwb/vite-plugin-mock/issues/40) ([f25c6ac](https://github.com/anncwb/vite-plugin-mock/commit/f25c6ac8544991457368746bf6ec5fdfd8b4e083))\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- error handle, fix [#39](https://github.com/anncwb/vite-plugin-mock/issues/39) ([874318c](https://github.com/anncwb/vite-plugin-mock/commit/874318ce399dc78c33d91161b73e3ced7bb6e9b6))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- fix node version ([#38](https://github.com/anncwb/vite-plugin-mock/issues/38)) ([f91dea1](https://github.com/anncwb/vite-plugin-mock/commit/f91dea1be943aa1145727bfecd273ef45cdff8e9))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n- **server:** add this for response, rawResponse function ([#43](https://github.com/anncwb/vite-plugin-mock/issues/43)) ([2f4d6d2](https://github.com/anncwb/vite-plugin-mock/commit/2f4d6d2984c7fe15236cb8b0d2ec5479930d5668))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.9.4](https://github.com/anncwb/vite-plugin-mock/compare/v2.9.0...v2.9.4) (2021-08-01)\n\n### Bug Fixes\n\n- can't update in real time, fix [#40](https://github.com/anncwb/vite-plugin-mock/issues/40) ([f25c6ac](https://github.com/anncwb/vite-plugin-mock/commit/f25c6ac8544991457368746bf6ec5fdfd8b4e083))\n- error handle, fix [#39](https://github.com/anncwb/vite-plugin-mock/issues/39) ([874318c](https://github.com/anncwb/vite-plugin-mock/commit/874318ce399dc78c33d91161b73e3ced7bb6e9b6))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- fix node version ([#38](https://github.com/anncwb/vite-plugin-mock/issues/38)) ([f91dea1](https://github.com/anncwb/vite-plugin-mock/commit/f91dea1be943aa1145727bfecd273ef45cdff8e9))\n\n## [2.9.3](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.3) (2021-07-18)\n\n### Bug Fixes\n\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.9.2](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.2) (2021-07-18)\n\n### Bug Fixes\n\n- ensure file changes take effect,fix [#36](https://github.com/anncwb/vite-plugin-mock/issues/36) ([353aa9d](https://github.com/anncwb/vite-plugin-mock/commit/353aa9db67483072a3d60b6bf3c99736563bba43))\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- fix js parsing error ([1dbee45](https://github.com/anncwb/vite-plugin-mock/commit/1dbee452ec7d90b07ac86ce8530430e864589ab5))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.9.1](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.1) (2021-07-06)\n\n### Bug Fixes\n\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- fix js parsing error ([d2746b6](https://github.com/anncwb/vite-plugin-mock/commit/d2746b6d788cdd304cac8512afa743b01edbd479))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n# [2.9.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.9.0) (2021-07-05)\n\n### Bug Fixes\n\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([4cb55f8](https://github.com/anncwb/vite-plugin-mock/commit/4cb55f87def1e3edf07937ce48b0cfc594f2b88d))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([4625e59](https://github.com/anncwb/vite-plugin-mock/commit/4625e59429b4fc06ff4f911d681ee4999661c3ec))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n# [2.8.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.8.0) (2021-06-16)\n\n### Bug Fixes\n\n- ensure that the post with parameters are matched,fix [#29](https://github.com/anncwb/vite-plugin-mock/issues/29) ([bfed256](https://github.com/anncwb/vite-plugin-mock/commit/bfed256bff42e2348b30a6b31746854b18fc90b8))\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- remove supportTs, change to automatic judgment ([a341c7d](https://github.com/anncwb/vite-plugin-mock/commit/a341c7d5b2de153593c0d1f5dab00b1b730a6819))\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.7.2](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.7.2) (2021-06-10)\n\n### Bug Fixes\n\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- make sure ignore matches the file correctly ([b612a09](https://github.com/anncwb/vite-plugin-mock/commit/b612a0934b7dcaae423450a56139cc9b9749c43e))\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n## [2.7.1](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.7.1) (2021-06-09)\n\n### Bug Fixes\n\n- improve path matching logic, fix [#25](https://github.com/anncwb/vite-plugin-mock/issues/25) ([5079e4b](https://github.com/anncwb/vite-plugin-mock/commit/5079e4ba1c713aaba2facc87dfb289ea0916c231))\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n- support node12 ([fdfed60](https://github.com/anncwb/vite-plugin-mock/commit/fdfed60b6d8859bdcf8292c30859101f47d758b5))\n\n### Features\n\n- response return url ([#27](https://github.com/anncwb/vite-plugin-mock/issues/27)) ([de9ed27](https://github.com/anncwb/vite-plugin-mock/commit/de9ed276b61c18cdfe0509df21921bc3ddf9d767))\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n# [2.6.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.5.0...v2.6.0) (2021-05-29)\n\n### Bug Fixes\n\n- loss request headers in PROD mode ([#23](https://github.com/anncwb/vite-plugin-mock/issues/23)) ([76302df](https://github.com/anncwb/vite-plugin-mock/commit/76302df9cc5a23fe0ccd001787bffbb4c012cc83)), closes [#15](https://github.com/anncwb/vite-plugin-mock/issues/15)\n\n### Reverts\n\n- revert 2.5.0, fix [#22](https://github.com/anncwb/vite-plugin-mock/issues/22) ([d5ac0d6](https://github.com/anncwb/vite-plugin-mock/commit/d5ac0d68a67f4e4cc568ef1eff12f2ba425553e8))\n\n# [2.5.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.4.0...v2.5.0) (2021-04-06)\n\n### Bug Fixes\n\n- production xhr ([6c94783](https://github.com/anncwb/vite-plugin-mock/commit/6c94783f07b27c6ac58a4642c0e7eddf34b06f1f))\n- **eslint warn:** fix some warn ([b44c13b](https://github.com/anncwb/vite-plugin-mock/commit/b44c13b766cda0ee310071e9febeb48d73ef7bde))\n- empty TS file in mock folder is error ([669b804](https://github.com/anncwb/vite-plugin-mock/commit/669b804df31f537bf6985b56972b32dd11e20504))\n\n### Features\n\n- add rawResponse option to MockMethod ([#17](https://github.com/anncwb/vite-plugin-mock/issues/17)) ([24775f9](https://github.com/anncwb/vite-plugin-mock/commit/24775f9d7b14d024d90cd36c850a00634341927f)), closes [#16](https://github.com/anncwb/vite-plugin-mock/issues/16)\n\n### Performance Improvements\n\n- perf code ([98b9dbc](https://github.com/anncwb/vite-plugin-mock/commit/98b9dbc64f5c6da815a1f29c6b588fddd5189370))\n\n## [2.4.1](https://github.com/anncwb/vite-plugin-mock/compare/v2.4.0...v2.4.1) (2021-03-30)\n\n### Bug Fixes\n\n- empty TS file in mock folder is error ([669b804](https://github.com/anncwb/vite-plugin-mock/commit/669b804df31f537bf6985b56972b32dd11e20504))\n\n### Performance Improvements\n\n- perf code ([98b9dbc](https://github.com/anncwb/vite-plugin-mock/commit/98b9dbc64f5c6da815a1f29c6b588fddd5189370))\n\n# [2.4.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.3.0...v2.4.0) (2021-03-25)\n\n### Features\n\n- response return headers, close [#10](https://github.com/anncwb/vite-plugin-mock/issues/10) ([bcb7abd](https://github.com/anncwb/vite-plugin-mock/commit/bcb7abd98e8726af6f1721ad021c06028b1ffca7))\n\n## [2.2.4](https://github.com/anncwb/vite-plugin-mock/compare/v2.2.3...v2.2.4) (2021-03-10)\n\n### Features\n\n- support post restful close [#7](https://github.com/anncwb/vite-plugin-mock/issues/7) ([70b51e8](https://github.com/anncwb/vite-plugin-mock/commit/70b51e8738e41a7011e38e942dd2a136e450ae9f))\n\n## [2.2.3](https://github.com/anncwb/vite-plugin-mock/compare/v2.2.0...v2.2.3) (2021-03-10)\n\n### Bug Fixes\n\n- ensure that the URLs of different request methods cannot match close [#6](https://github.com/anncwb/vite-plugin-mock/issues/6) ([361a3eb](https://github.com/anncwb/vite-plugin-mock/commit/361a3eb62874f7a6dce8cdc8add4487302c3ee04))\n\n### Features\n\n- support restful api close [#4](https://github.com/anncwb/vite-plugin-mock/issues/4) ([236393e](https://github.com/anncwb/vite-plugin-mock/commit/236393ef551de32fbba62fbb27f678d4782568ec))\n\n## [2.2.1](https://github.com/anncwb/vite-plugin-mock/compare/v2.2.0...v2.2.1) (2021-03-09)\n\n### Features\n\n- support restful api close [#4](https://github.com/anncwb/vite-plugin-mock/issues/4) ([7a35b1a](https://github.com/anncwb/vite-plugin-mock/commit/7a35b1a3af3bfa8623f1d24f53e71928df20b69b))\n\n# [2.2.0](https://github.com/anncwb/vite-plugin-mock/compare/v2.1.5...v2.2.0) (2021-03-02)\n\n### Features\n\n- add logger option ([66a75ab](https://github.com/anncwb/vite-plugin-mock/commit/66a75ab0ee5a7c8e03987e74f15b50aedd1cc29f))\n\n## [2.1.5](https://github.com/anncwb/vite-plugin-mock/compare/v2.0.0-beta.1...v2.1.5) (2021-02-23)\n\n### Bug Fixes\n\n- correct sourcemap ([2140987](https://github.com/anncwb/vite-plugin-mock/commit/21409876876b845b18b5b006e98292138870a922))\n- dev sourcemap ([5834b4f](https://github.com/anncwb/vite-plugin-mock/commit/5834b4f621b25371a7b0246a48fb83b9761afeed))\n- fix post proxy error ([d3ae41e](https://github.com/anncwb/vite-plugin-mock/commit/d3ae41e18a5e7adae504457165ba7b34b8ebff6f))\n\n### Features\n\n- support sourcemap ([8c3cd9d](https://github.com/anncwb/vite-plugin-mock/commit/8c3cd9d78a9bd7f87dc7900e9bfe6c753ff3b11f))\n\n### Performance Improvements\n\n- imporve request log ([f9353fd](https://github.com/anncwb/vite-plugin-mock/commit/f9353fdf8149665f984729ab3c7a6749022cfdaf))\n\n# [2.0.0-beta.1](https://github.com/anncwb/vite-plugin-mock/compare/2.0.0-beta.1...v2.0.0-beta.1) (2021-01-03)\n\n### Bug Fixes\n\n- Fix local development post request proxy to https ([7965604](https://github.com/anncwb/vite-plugin-mock/commit/79656046377f501da796d1be9752522a2203d69b))\n- remove unnecessary and wrong usage of \"try catch\" ([815abde](https://github.com/anncwb/vite-plugin-mock/commit/815abde26f8f9a19322916ae01a9896a9aced33a))\n\n### Features\n\n- add request time ([ccbb14a](https://github.com/anncwb/vite-plugin-mock/commit/ccbb14ad623e6549781e5e902819f830a291f13f))\n\n## [1.0.2](https://github.com/anncwb/vite-plugin-mock/compare/1.0.1...1.0.2) (2020-09-14)\n\n### Features\n\n- add examples ([2c5a86b](https://github.com/anncwb/vite-plugin-mock/commit/2c5a86bb75e39b6c7c9e08b1691c0541aeb104d9))\n\n## [1.0.1](https://github.com/anncwb/vite-plugin-mock/compare/58ad7cd57e3fd0daa92e0fc59c00e09cf6ba45ad...1.0.1) (2020-09-14)\n\n### Features\n\n- add supportTs options,Support es6 and commonjs modules in .js folder ([37f83f5](https://github.com/anncwb/vite-plugin-mock/commit/37f83f54c3a34e049f967b0db0ac2ade401cbf58))\n\n### Performance Improvements\n\n- Replace typescript plug-in with a faster esbuild plug-in ([58ad7cd](https://github.com/anncwb/vite-plugin-mock/commit/58ad7cd57e3fd0daa92e0fc59c00e09cf6ba45ad))\n"
  },
  {
    "path": "packages/vite-plugin-mock/build.config.ts",
    "content": "import { defineBuildConfig } from 'unbuild'\n\nexport default defineBuildConfig({\n  clean: true,\n  entries: ['src/index', 'src/client'],\n  declaration: true,\n  rollup: {\n    emitCJS: true,\n  },\n})\n"
  },
  {
    "path": "packages/vite-plugin-mock/package.json",
    "content": "{\n  \"name\": \"vite-plugin-mock\",\n  \"version\": \"3.0.2\",\n  \"description\": \"A mock plugin for vite\",\n  \"main\": \"dist/index.cjs\",\n  \"module\": \"dist/index.mjs\",\n  \"types\": \"dist/index.d.ts\",\n  \"exports\": {\n    \".\": {\n      \"types\": \"./dist/index.d.ts\",\n      \"import\": \"./dist/index.mjs\",\n      \"require\": \"./dist/index.cjs\"\n    },\n    \"./client\": {\n      \"types\": \"./dist/client.d.ts\",\n      \"import\": \"./dist/client.mjs\",\n      \"require\": \"./dist/client.cjs\"\n    }\n  },\n  \"files\": [\n    \"dist\"\n  ],\n  \"type\": \"module\",\n  \"engines\": {\n    \"node\": \">=16.0.0\"\n  },\n  \"scripts\": {\n    \"clean\": \"rimraf dist && rimraf es\",\n    \"dev\": \"unbuild --stub\",\n    \"build\": \"unbuild\",\n    \"log\": \"conventional-changelog -p angular -i CHANGELOG.md -s\",\n    \"prepublishOnly\": \"npm run build\"\n  },\n  \"keywords\": [\n    \"vite\",\n    \"mock\",\n    \"hmr\"\n  ],\n  \"author\": \"Vben\",\n  \"license\": \"MIT\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/anncwb/vite-plugin-mock\",\n    \"directory\": \"packages/vite-plugin-mock\"\n  },\n  \"bugs\": {\n    \"url\": \"https://github.com/anncwb/vite-plugin-mock/issues\"\n  },\n  \"homepage\": \"https://github.com/anncwb/vite-plugin-mock/tree/master/#readme\",\n  \"dependencies\": {\n    \"bundle-require\": \"^4.0.1\",\n    \"chokidar\": \"^3.5.3\",\n    \"connect\": \"^3.7.0\",\n    \"debug\": \"^4.3.4\",\n    \"fast-glob\": \"^3.2.12\",\n    \"path-to-regexp\": \"^6.2.1\",\n    \"picocolors\": \"^1.0.0\"\n  },\n  \"peerDependencies\": {\n    \"mockjs\": \">=1.1.0\",\n    \"vite\": \">=4.0.0\",\n    \"esbuild\": \">=0.17\"\n  },\n  \"devDependencies\": {\n    \"@types/mockjs\": \"^1.0.7\",\n    \"@types/connect\": \"^3.4.35\",\n    \"@types/debug\": \"^4.1.7\",\n    \"@types/node\": \"^16.18.23\",\n    \"mockjs\": \"^1.1.0\",\n    \"rimraf\": \"^5.0.0\",\n    \"tsup\": \"6.7.0\",\n    \"typescript\": \"^5.0.4\",\n    \"unbuild\": \"^1.2.1\",\n    \"vite\": \"4.2.1\"\n  }\n}\n"
  },
  {
    "path": "packages/vite-plugin-mock/src/client.ts",
    "content": "/* eslint-disable */\nimport type { MockMethod } from './types'\n\nexport async function createProdMockServer(mockList: any[]) {\n  const Mock: any = await import('mockjs')\n  const { pathToRegexp } = await import('path-to-regexp')\n  Mock.XHR.prototype.__send = Mock.XHR.prototype.send\n  Mock.XHR.prototype.send = function () {\n    if (this.custom.xhr) {\n      this.custom.xhr.withCredentials = this.withCredentials || false\n\n      if (this.responseType) {\n        this.custom.xhr.responseType = this.responseType\n      }\n    }\n    if (this.custom.requestHeaders) {\n      const headers: any = {}\n      for (let k in this.custom.requestHeaders) {\n        headers[k.toString().toLowerCase()] = this.custom.requestHeaders[k]\n      }\n      this.custom.options = Object.assign({}, this.custom.options, { headers })\n    }\n    this.__send.apply(this, arguments)\n  }\n\n  Mock.XHR.prototype.proxy_open = Mock.XHR.prototype.open\n\n  Mock.XHR.prototype.open = function () {\n    let responseType = this.responseType\n    this.proxy_open(...arguments)\n    if (this.custom.xhr) {\n      if (responseType) {\n        this.custom.xhr.responseType = responseType\n      }\n    }\n  }\n\n  for (const { url, method, response, timeout } of mockList) {\n    __setupMock__(Mock, timeout)\n    Mock.mock(\n      pathToRegexp(url, undefined, { end: false }),\n      method || 'get',\n      __XHR2ExpressReqWrapper__(Mock, response),\n    )\n  }\n}\n\nfunction __param2Obj__(url: string) {\n  const search = url.split('?')[1]\n  if (!search) {\n    return {}\n  }\n  return JSON.parse(\n    '{\"' +\n      decodeURIComponent(search)\n        .replace(/\"/g, '\\\\\"')\n        .replace(/&/g, '\",\"')\n        .replace(/=/g, '\":\"')\n        .replace(/\\+/g, ' ') +\n      '\"}',\n  )\n}\n\nfunction __XHR2ExpressReqWrapper__(_Mock: any, handle: (d: any) => any) {\n  return function (options: any) {\n    let result = null\n    if (typeof handle === 'function') {\n      const { body, type, url, headers } = options\n\n      let b = body\n      try {\n        b = JSON.parse(body)\n      } catch {}\n      result = handle({\n        method: type,\n        body: b,\n        query: __param2Obj__(url),\n        headers,\n      })\n    } else {\n      result = handle\n    }\n\n    return _Mock.mock(result)\n  }\n}\n\nfunction __setupMock__(mock: any, timeout = 0) {\n  timeout &&\n    mock.setup({\n      timeout,\n    })\n}\n\nexport function defineMockModule(\n  fn: (config: {\n    env: Record<string, any>\n    mode: string\n    command: 'build' | 'serve'\n  }) => Promise<MockMethod[]> | MockMethod[],\n) {\n  return fn\n}\n"
  },
  {
    "path": "packages/vite-plugin-mock/src/createMockServer.ts",
    "content": "import type { ViteMockOptions, MockMethod, Recordable, RespThisType } from './types'\n\nimport path from 'node:path'\nimport fs from 'node:fs'\nimport chokidar from 'chokidar'\nimport colors from 'picocolors'\nimport url from 'url'\nimport fg from 'fast-glob'\nimport Mock from 'mockjs'\nimport { pathToRegexp, match } from 'path-to-regexp'\nimport { isArray, isFunction, sleep, isRegExp, isAbsPath } from './utils'\nimport { IncomingMessage, NextHandleFunction } from 'connect'\nimport { bundleRequire, GetOutputFile, JS_EXT_RE } from 'bundle-require'\nimport type { ResolvedConfig } from 'vite'\n\nexport let mockData: MockMethod[] = []\n\nexport async function createMockServer(\n  opt: ViteMockOptions = { mockPath: 'mock', configPath: 'vite.mock.config' },\n  config: ResolvedConfig,\n) {\n  opt = {\n    mockPath: 'mock',\n    watchFiles: true,\n    configPath: 'vite.mock.config.ts',\n    logger: true,\n    cors: true,\n    ...opt,\n  }\n\n  if (mockData.length > 0) return\n  mockData = await getMockConfig(opt, config)\n  await createWatch(opt, config)\n}\n\n// request match\nexport async function requestMiddleware(opt: ViteMockOptions) {\n  const { logger = true } = opt\n  const middleware: NextHandleFunction = async (req, res, next) => {\n    let queryParams: {\n      query?: {\n        [key: string]: any\n      }\n      pathname?: string | null\n    } = {}\n\n    if (req.url) {\n      queryParams = url.parse(req.url, true)\n    }\n\n    const reqUrl = queryParams.pathname\n\n    const matchRequest = mockData.find((item) => {\n      if (!reqUrl || !item || !item.url) {\n        return false\n      }\n      if (item.method && item.method.toUpperCase() !== req.method) {\n        return false\n      }\n      return pathToRegexp(item.url).test(reqUrl)\n    })\n\n    if (matchRequest) {\n      const isGet = req.method && req.method.toUpperCase() === 'GET'\n      const { response, rawResponse, timeout, statusCode, url } = matchRequest\n\n      if (timeout) {\n        await sleep(timeout)\n      }\n\n      const urlMatch = match(url, { decode: decodeURIComponent })\n\n      let query = queryParams.query as any\n      if (reqUrl) {\n        if ((isGet && JSON.stringify(query) === '{}') || !isGet) {\n          const params = (urlMatch(reqUrl) as any).params\n          if (JSON.stringify(params) !== '{}') {\n            query = (urlMatch(reqUrl) as any).params || {}\n          } else {\n            query = queryParams.query || {}\n          }\n        }\n      }\n\n      const self: RespThisType = { req, res, parseJson: parseJson.bind(null, req) }\n      if (isFunction(rawResponse)) {\n        await rawResponse.bind(self)(req, res)\n      } else {\n        const body = await parseJson(req)\n        res.setHeader('Content-Type', 'application/json')\n        if (opt) {\n          res.setHeader('Access-Control-Allow-Credentials', true)\n          res.setHeader('Access-Control-Allow-Origin', req.headers.origin || '*')\n        }\n        res.statusCode = statusCode || 200\n        const mockResponse = isFunction(response)\n          ? response.bind(self)({ url: req.url as any, body, query, headers: req.headers })\n          : response\n        res.end(JSON.stringify(Mock.mock(mockResponse)))\n      }\n\n      logger && loggerOutput('request invoke', req.url!)\n      return\n    }\n    next()\n  }\n  return middleware\n}\n\n// create watch mock\nfunction createWatch(opt: ViteMockOptions, config: ResolvedConfig) {\n  const { configPath, logger, watchFiles } = opt\n\n  if (!watchFiles) {\n    return\n  }\n\n  const { absConfigPath, absMockPath } = getPath(opt)\n\n  if (process.env.VITE_DISABLED_WATCH_MOCK === 'true') {\n    return\n  }\n\n  const watchDir = []\n  const exitsConfigPath = fs.existsSync(absConfigPath)\n\n  exitsConfigPath && configPath ? watchDir.push(absConfigPath) : watchDir.push(absMockPath)\n\n  const watcher = chokidar.watch(watchDir, {\n    ignoreInitial: true,\n    // ignore files generated by `bundle require`\n    ignored: '**/_*.bundled_*.(mjs|cjs)',\n  })\n\n  watcher.on('all', async (event, file) => {\n    logger && loggerOutput(`mock file ${event}`, file)\n    mockData = await getMockConfig(opt, config)\n  })\n}\n\n// clear cache\nfunction cleanRequireCache(opt: ViteMockOptions) {\n  if (typeof require === 'undefined' || !require.cache) {\n    return\n  }\n  const { absConfigPath, absMockPath } = getPath(opt)\n  Object.keys(require.cache).forEach((file) => {\n    if (file === absConfigPath || file.indexOf(absMockPath) > -1) {\n      delete require.cache[file]\n    }\n  })\n}\n\nfunction parseJson(req: IncomingMessage): Promise<Recordable> {\n  return new Promise((resolve) => {\n    let jsonStr: Recordable = {}\n    let str = ''\n    req.on('data', function (chunk) {\n      str += chunk\n    })\n    req.on('end', () => {\n      try {\n        // json\n        jsonStr = JSON.parse(str)\n      } catch (e) {\n        // x-www-form-urlencoded\n        const params = new URLSearchParams(str)\n        const body: Recordable = {}\n        params.forEach((value, key) => {\n          body[key] = value\n        })\n        jsonStr = body\n      }\n      resolve(jsonStr)\n      return\n    })\n  })\n}\n// load mock .ts files and watch\nasync function getMockConfig(opt: ViteMockOptions, config: ResolvedConfig) {\n  const { absConfigPath, absMockPath } = getPath(opt)\n  const { ignore, configPath, logger } = opt\n\n  let ret: MockMethod[] = []\n\n  if (configPath && fs.existsSync(absConfigPath)) {\n    logger && loggerOutput(`load mock data from`, absConfigPath)\n    ret = await resolveModule(absConfigPath, config)\n    return ret\n  }\n\n  const mockFiles = fg\n    .sync(`**/*.{ts,mjs,js}`, {\n      cwd: absMockPath,\n    })\n    .filter((item) => {\n      if (!ignore) {\n        return true\n      }\n      if (isFunction(ignore)) {\n        return !ignore(item)\n      }\n      if (isRegExp(ignore)) {\n        return !ignore.test(path.basename(item))\n      }\n      return true\n    })\n\n  try {\n    ret = []\n    const resolveModulePromiseList = []\n\n    for (let index = 0; index < mockFiles.length; index++) {\n      const mockFile = mockFiles[index]\n      resolveModulePromiseList.push(resolveModule(path.join(absMockPath, mockFile), config))\n    }\n\n    const loadAllResult = await Promise.all(resolveModulePromiseList)\n    for (const resultModule of loadAllResult) {\n      let mod = resultModule\n      if (!isArray(mod)) {\n        mod = [mod]\n      }\n      ret = [...ret, ...mod]\n    }\n  } catch (error: any) {\n    loggerOutput(`mock reload error`, error)\n    ret = []\n  }\n  return ret\n}\n\n// fixed file generation format\n// use a random path to avoid import cache\nconst getOutputFile: GetOutputFile = (filepath, format) => {\n  const dirname = path.dirname(filepath)\n  const basename = path.basename(filepath)\n  const randomname = `${Date.now()}_${Math.random().toString(36).substring(2, 15)}`\n  return path.resolve(\n    dirname,\n    `_${basename.replace(JS_EXT_RE, `.bundled_${randomname}.${format === 'esm' ? 'mjs' : 'cjs'}`)}`,\n  )\n}\n\n// Inspired by vite\n// support mock .ts files\nasync function resolveModule(p: string, config: ResolvedConfig): Promise<any> {\n  const mockData = await bundleRequire({\n    filepath: p,\n    getOutputFile,\n  })\n\n  let mod = mockData.mod.default || mockData.mod\n  if (isFunction(mod)) {\n    mod = await mod({ env: config.env, mode: config.mode, command: config.command })\n  }\n  return mod\n}\n\n// get custom config file path and mock dir path\nfunction getPath(opt: ViteMockOptions) {\n  const { mockPath, configPath } = opt\n  const cwd = process.cwd()\n  const absMockPath = isAbsPath(mockPath) ? mockPath! : path.join(cwd, mockPath || '')\n  const absConfigPath = path.join(cwd, configPath || '')\n  return {\n    absMockPath,\n    absConfigPath,\n  }\n}\n\nfunction loggerOutput(title: string, msg: string, type: 'info' | 'error' = 'info') {\n  const tag = type === 'info' ? colors.cyan(`[vite:mock]`) : colors.red(`[vite:mock-server]`)\n  return console.log(\n    `${colors.dim(new Date().toLocaleTimeString())} ${tag} ${colors.green(title)} ${colors.dim(\n      msg,\n    )}`,\n  )\n}\n"
  },
  {
    "path": "packages/vite-plugin-mock/src/index.ts",
    "content": ";(async () => {\n  try {\n    await import('mockjs')\n  } catch (e) {\n    throw new Error('vite-plugin-vue-mock requires mockjs to be present in the dependency tree.')\n  }\n})()\n\nimport type { ViteMockOptions } from './types'\nimport type { Plugin } from 'vite'\nimport { ResolvedConfig } from 'vite'\nimport { createMockServer, requestMiddleware } from './createMockServer'\n\nexport function viteMockServe(opt: ViteMockOptions = {}): Plugin {\n  let isDev = false\n  let config: ResolvedConfig\n\n  return {\n    name: 'vite:mock',\n    enforce: 'pre' as const,\n    configResolved(resolvedConfig) {\n      config = resolvedConfig\n      isDev = config.command === 'serve'\n      isDev && createMockServer(opt, config)\n    },\n\n    configureServer: async ({ middlewares }) => {\n      const { enable = isDev } = opt\n      if (!enable) {\n        return\n      }\n      const middleware = await requestMiddleware(opt)\n      middlewares.use(middleware)\n    },\n  }\n}\n\nexport * from './types'\n"
  },
  {
    "path": "packages/vite-plugin-mock/src/types.ts",
    "content": "import { IncomingMessage, ServerResponse } from 'http'\n\nexport interface ViteMockOptions {\n  mockPath?: string\n  configPath?: string\n  ignore?: RegExp | ((fileName: string) => boolean)\n  watchFiles?: boolean\n  enable?: boolean\n  logger?: boolean\n  cors?: boolean\n}\n\nexport interface RespThisType {\n  req: IncomingMessage\n  res: ServerResponse\n  parseJson: () => any\n}\n\nexport type MethodType = 'get' | 'post' | 'put' | 'delete' | 'patch'\n\nexport type Recordable<T = any> = Record<string, T>\n\nexport declare interface MockMethod {\n  url: string\n  method?: MethodType\n  timeout?: number\n  statusCode?: number\n  response?:\n    | ((\n        this: RespThisType,\n        opt: { url: Recordable; body: Recordable; query: Recordable; headers: Recordable },\n      ) => any)\n    | any\n  rawResponse?: (this: RespThisType, req: IncomingMessage, res: ServerResponse) => void\n}\n\nexport interface MockConfig {\n  env: Record<string, any>\n  mode: string\n  command: 'build' | 'serve'\n}\n"
  },
  {
    "path": "packages/vite-plugin-mock/src/utils.ts",
    "content": "import fs from 'fs'\n\nconst toString = Object.prototype.toString\n\nexport function is(val: unknown, type: string) {\n  return toString.call(val) === `[object ${type}]`\n}\n\n// eslint-disable-next-line\nexport function isFunction<T = Function>(val: unknown): val is T {\n  return is(val, 'Function') || is(val, 'AsyncFunction')\n}\n\nexport function isArray(val: any): val is Array<any> {\n  return val && Array.isArray(val)\n}\n\nexport function isRegExp(val: unknown): val is RegExp {\n  return is(val, 'RegExp')\n}\n\nexport function isAbsPath(path: string | undefined) {\n  if (!path) {\n    return false\n  }\n  // Windows 路径格式：C:\\ 或 \\\\ 开头，或已含盘符（D:\\path\\to\\file）\n  if (/^([a-zA-Z]:\\\\|\\\\\\\\|(?:\\/|\\uFF0F){2,})/.test(path)) {\n    return true\n  }\n  // Unix/Linux 路径格式：/ 开头\n  return /^\\/[^/]/.test(path)\n}\n\nexport function sleep(time: number) {\n  return new Promise((resolve) => {\n    setTimeout(() => {\n      resolve('')\n    }, time)\n  })\n}\n"
  },
  {
    "path": "packages/vite-plugin-mock/tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"strict\": true,\n    \"declaration\": true,\n    \"noUnusedLocals\": true,\n    \"esModuleInterop\": true,\n    \"outDir\": \"dist\",\n    \"module\": \"commonjs\",\n    \"lib\": [\"ESNext\"],\n    \"types\": [\"vite/client\", \"node\"],\n    \"sourceMap\": false,\n    \"noEmitOnError\": true\n  },\n  \"include\": [\"src\", \"tests\"],\n  \"exclude\": [\"**/dist/**\", \"**/node_modules/**\"]\n}\n"
  },
  {
    "path": "pnpm-workspace.yaml",
    "content": "packages:\n  - 'packages/*'\n  - 'packages/playground/*'\n"
  },
  {
    "path": "prettier.config.js",
    "content": "module.exports = {\n  printWidth: 100,\n  tabWidth: 2,\n  useTabs: false,\n  semi: false,\n  singleQuote: true,\n  trailingComma: 'all',\n}\n"
  },
  {
    "path": "tests/index.spec.ts",
    "content": "// import { discreteDir } from '../src/index';\n// test('discreteDir Not included /', () => {\n//   const { fileName, dirName } = discreteDir('file.svg');\n\n//   expect(fileName).toBe('file.svg');\n//   expect(dirName).toBe('');\n// });\n"
  },
  {
    "path": "tsconfig.es.json",
    "content": "{\n  \"extends\": \"./tsconfig.json\",\n  \"compilerOptions\": {\n    \"module\": \"esnext\",\n    \"outDir\": \"es\"\n  },\n  \"include\": [\"./src/createProdMockServer.ts\"],\n  \"exclude\": [\"**/dist/**\", \"**/node_modules/**\"]\n}\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"strict\": true,\n    \"declaration\": true,\n    \"noUnusedLocals\": true,\n    \"esModuleInterop\": true,\n    \"outDir\": \"dist\",\n    \"module\": \"commonjs\",\n    \"lib\": [\"ESNext\"],\n    \"types\": [\"vite/client\", \"node\"],\n    \"sourceMap\": false,\n    \"noEmitOnError\": true\n  },\n  \"include\": [\"src\", \"tests\"],\n  \"exclude\": [\"**/dist/**\", \"**/node_modules/**\"]\n}\n"
  }
]