文档系统基于开源项目 docusaurus-openapi 此系统在docusaurus的基础上集成了openapi的支持, 支持Try it!api调试功能

版本信息

node v16.15.1
yarn v12.22.10
docusaurus 2.0.0-beta.14

Step1

根据 ISSUE160 在package.json中添加下面的配置,以指定使用docusaurus2.0.0-beta.14版本

  "resolutions": {
    "@docusaurus/core": "2.0.0-beta.14",
    "@docusaurus/preset-classic": "2.0.0-beta.14",
    "@docusaurus/mdx-loader": "2.0.0-beta.14",
    "@docusaurus/plugin-content-docs": "2.0.0-beta.14",
    "@docusaurus/types": "2.0.0-beta.14",
    "@docusaurus/utils-validation": "2.0.0-beta.14",
    "@docusaurus/utils": "2.0.0-beta.14"
  },

Step2

yarn install
yarn build

问题

Module not found: Error: Can't resolve 'url' in '/Users/junqiang/workspace/test/docus-open/my-website/node_modules/postman-url-encoder/encoder'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
	- install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "url": false }
Module not found: Error: Can't resolve 'url' in '/Users/junqiang/workspace/test/docus-open/my-website/node_modules/sanitize-html/dist'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
	- install 'url'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "url": false }
client (webpack 5.73.0) compiled with 2 errors

从问题提示看是webpack新版本和polyfill版本的问题,执行 执行

❯ yarn add polyfill //执行后依然有问题,看提示 install url ,执行下一步
❯ yarn add url
❯ yarn build
yarn run v1.22.17
$ docusaurus build

   ╭────────────────────────────────────────────────────────────────────────────────────────╮
   │                                                                                        │
   │                     Update available 2.0.0-beta.14 → 2.0.0-beta.22                     │
   │                                                                                        │
   │   To upgrade Docusaurus packages with the latest version, run the following command:   │
`yarn upgrade @docusaurus/core@latest`   │                                                                                        │
   ╰────────────────────────────────────────────────────────────────────────────────────────╯

[INFO] [en] Creating an optimized production build...

✔ Client
  

✔ Server
  Compiled successfully in 4.22s


✔ Client
  

● Server █████████████████████████ cache (99%) shutdown IdleFileCachePlugin
 stored

[SUCCESS] Generated static files in build.
[INFO] Use `npm run serve` command to test your build locally.
✨  Done in 6.13s.

test/docus-open/my-website via  v16.15.1 took 6s 
❯ cd build 
❯ ls
404.html      api           assets        blog          docs          img           index.html    markdown-page sitemap.xml

– END –