\r\n\r\nIt is inevitable to use `document` in `vitepress` many times, but how to avoid the packaging error when` vitepress` uses the server-side rendering method?\r\n\r\nAre there any third-party plug-in recommendations or configuration items?\n\n### Reproduction\n\n```vue\r\n\u003Cscript setup>\r\n console.log(document)\r\n\u003C/script>\r\n```\r\n\r\n\r\n\n\n### Expected behavior\n\nBuild ok\n\n### System Info\n\n```shell\n\"vitepress\": \"^1.0.0-alpha.4\",\r\n\"vue\": \"^3.2.33\"\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [X] Read the [docs](https://vitepress.vuejs.org).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[3090],{"name":3042,"color":3043},1120,"document is not defined","2023-01-21T14:28:51Z","https://github.com/vuejs/vitepress/issues/1120",0.6603922,{"description":3097,"labels":3098,"number":3105,"owner":3023,"repository":3024,"state":3025,"title":3106,"updated_at":3107,"url":3108,"score":3109},"### Describe the bug\n\nwhen run `pnpm build`, it wil show this error message:\r\n```\r\nSyntaxError: The requested module '@vueuse/shared' does not provide an export named 'resolveRef'\r\n at ModuleJob._instantiate (node:internal/modules/esm/module_job:127:21)\r\n at async ModuleJob.run (node:internal/modules/esm/module_job:193:5)\r\n at async Promise.all (index 0)\r\n at async ESMLoader.import (node:internal/modules/esm/loader:337:24)\r\n at async build (file:///Users/bou/working/code/vue-pro/sinogear-frontend-pro-vue/node_modules/.pnpm/vitepress@1.0.0-alpha.30_less@4.1.3/node_modules/vitepress/dist/node/serve-e6561b64.js:42006:24)\r\n ELIFECYCLE Command failed with exit code 1.\r\n \r\n```\r\n\r\n\n\n### Reproduction\n\n- I have import a Self-developed components in `docs/.vitepress/theme/index.js`:\r\n\r\n```\r\nimport SgVue from '../../../lib/index.js';\r\n```\r\n\r\n- config in `/docs/.vitepress/config.js`:\r\n```\r\nimport { defineConfigWithTheme } from 'vitepress';\r\nimport vueJsx from '@vitejs/plugin-vue-jsx';\r\nimport baseConfig from '@vue/theme/config';\r\nimport { demoBlockPlugin } from 'vitepress-theme-demoblock';\r\nimport { SearchPlugin } from 'vitepress-plugin-search';\r\n\r\nimport { i18n, nav, sidebar } from './config/index';\r\n\r\nexport default defineConfigWithTheme({\r\n extends: baseConfig,\r\n lang: 'zh-CN',\r\n title: 'Sg Vue',\r\n description: 'Vue2.7.0+版本开发文档',\r\n srcDir: 'src',\r\n // srcExclude: ['tutorial/**/description.md'],\r\n scrollOffset: 'header',\r\n ignoreDeadLinks: true,\r\n head: [['meta', { name: 'theme-color', content: '#3c8772' }]],\r\n themeConfig: {\r\n nav,\r\n sidebar,\r\n appearance: false, // 开启 light/dark 模式\r\n // Placeholder of the i18n config for @vuejs-translations.\r\n i18n,\r\n footer: {\r\n copyright: `©2006-${new Date().getFullYear()}`\r\n }\r\n },\r\n\r\n markdown: {\r\n config(md) {\r\n // demoBlockPlugin 基于 Vitepress 的主题插件,在编写文档的时候增加 Vue 示例\r\n md.use(demoBlockPlugin, {\r\n cssPreprocessor: 'less',\r\n //markdown 中的vue代码被编译为了 vue 函数组件,需要把 import 转换为 require\r\n scriptImports: [\r\n \"import * as AntDesignVue from 'ant-design-vue'\",\r\n \"import * as SinogearVue from '../../../lib/index.js'\",\r\n \"import * as AntDesignVueIcons from '@ant-design/icons-vue'\"\r\n ],\r\n scriptReplaces: [\r\n {\r\n searchValue: /const ({ defineComponent as _defineComponent }) = Vue/g,\r\n replaceValue: 'const { defineComponent: _defineComponent } = Vue'\r\n },\r\n {\r\n searchValue: /import ({.*}) from 'ant-design-vue'/g,\r\n replaceValue: (s, s1) => `const ${s1} = AntDesignVue`\r\n },\r\n {\r\n searchValue: /import ({.*}) from '..\\/..\\/..\\/lib\\/index.js'/g,\r\n replaceValue: (s, s1) => `const ${s1} = SinogearVue`\r\n },\r\n {\r\n searchValue: /import ({.*}) from '@ant-design\\/icons-vue'/g,\r\n replaceValue: (s, s1) => `const ${s1} = AntDesignVueIcons`\r\n }\r\n ]\r\n });\r\n }\r\n },\r\n\r\n vite: {\r\n server: {\r\n host: true,\r\n port: 3001,\r\n fs: {\r\n // for when developing with locally linked theme\r\n allow: ['../..']\r\n }\r\n },\r\n build: {\r\n minify: 'terser',\r\n chunkSizeWarningLimit: Infinity\r\n },\r\n json: {\r\n stringify: true\r\n },\r\n plugins: [\r\n vueJsx(),\r\n SearchPlugin({\r\n tokenize: 'full'\r\n })\r\n ],\r\n css: {\r\n preprocessorOptions: {\r\n less: {\r\n javascriptEnabled: true\r\n }\r\n }\r\n }\r\n },\r\n\r\n vue: {\r\n reactivityTransform: true\r\n }\r\n});\r\n\r\n```\r\n\r\n- It's OK on Dev\r\n\r\n- Run `pnpm build`\r\n\n\n### Expected behavior\n\nno error show \n\n### System Info\n\n```shell\n`\"vitepress\": \"^1.0.0-alpha.28\"`\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [X] Read the [docs](https://vitepress.vuejs.org).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[3099,3102],{"name":3100,"color":3101},"need more info","bdbefc",{"name":3103,"color":3104},"stale","ededed",1679,"The requested module '@vueuse/shared' does not provide an export named 'resolveRef'","2023-08-13T00:04:21Z","https://github.com/vuejs/vitepress/issues/1679",0.660654,{"description":3111,"labels":3112,"number":3114,"owner":3023,"repository":3024,"state":3025,"title":3115,"updated_at":3116,"url":3117,"score":3118},"### Describe the bug\n\nWe use VitePress to build a demo website for a component library. To allow the Vue browser tools to work on this demo website, we would like to build and publish the website in production mode.\r\n\r\nI thought that adding `mode: 'development'` to our `vite.config.ts` would accomplish this, but it throws errors like this when building:\r\n```\r\n⠦ rendering pages...Error: Cannot find module '/introduction/usage.md?t=1649205963799'\r\nRequire stack:\r\n- /home/catrope/git/codex/packages/codex-docs/docs/.vitepress/.temp/app.js\r\n- /home/catrope/git/codex/packages/codex-docs/node_modules/vitepress/dist/node/serve-9874c5ac.js\r\n- /home/catrope/git/codex/packages/codex-docs/node_modules/vitepress/dist/node/cli.js\r\n- /home/catrope/git/codex/packages/codex-docs/node_modules/vitepress/bin/vitepress.js\r\n at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)\r\n at Function.Module._load (node:internal/modules/cjs/loader:778:27)\r\n at Module.require (node:internal/modules/cjs/loader:1005:19)\r\n at require (node:internal/modules/cjs/helpers:94:18)\r\n at /home/catrope/git/codex/packages/codex-docs/docs/.vitepress/.temp/app.js:2098:12\r\n at loadPage (/home/catrope/git/codex/packages/codex-docs/docs/.vitepress/.temp/app.js:185:18)\r\n at Object.go (/home/catrope/git/codex/packages/codex-docs/docs/.vitepress/.temp/app.js:178:12)\r\n at renderPage (/home/catrope/git/codex/packages/codex-docs/node_modules/vitepress/dist/node/serve-9874c5ac.js:40217:10)\r\n at Object.build (/home/catrope/git/codex/packages/codex-docs/node_modules/vitepress/dist/node/serve-9874c5ac.js:40362:15) {\r\n code: 'MODULE_NOT_FOUND',\r\n requireStack: [\r\n '/home/catrope/git/codex/packages/codex-docs/docs/.vitepress/.temp/app.js',\r\n '/home/catrope/git/codex/packages/codex-docs/node_modules/vitepress/dist/node/serve-9874c5ac.js',\r\n '/home/catrope/git/codex/packages/codex-docs/node_modules/vitepress/dist/node/cli.js',\r\n '/home/catrope/git/codex/packages/codex-docs/node_modules/vitepress/bin/vitepress.js'\r\n ]\r\n}\r\n```\r\nThis error repeats for every Markdown file. The build then says it has succeeded, and it does produce a directory structure with HTML files, but all of them contain a 404 error page.\r\n\r\nI also tried adding `vue: { isProduction: false }` to the VitePress config, but that doesn't appear to make the development tools work.\n\n### Reproduction\n\n- In `docs/vite.config.ts`,add `mode: 'development'` at the top level (our full Vite config is [here](https://github.com/wikimedia/design-codex/blob/main/packages/codex-docs/docs/vite.config.ts))\r\n- Run `vitepress build docs`\r\n- Lots of errors are thrown, and a build is generated that contains only 404 pages\n\n### Expected behavior\n\nA static site is built that has the correct content in it (not just 404 pages), and that uses the development build of Vue rather than the production build. At minimum, enabling development mode shouldn't blow everything up.\n\n### System Info\n\n```shell\nSystem:\r\n OS: Linux 5.4 Ubuntu 20.04.4 LTS (Focal Fossa)\r\n CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz\r\n Memory: 1.89 GB / 15.39 GB\r\n Container: Yes\r\n Shell: 5.0.17 - /bin/bash\r\n Binaries:\r\n Node: 16.9.1 - ~/.nvm/versions/node/v16.9.1/bin/node\r\n Yarn: 1.22.11 - ~/.nvm/versions/node/v16.9.1/bin/yarn\r\n npm: 8.5.3 - ~/.nvm/versions/node/v16.9.1/bin/npm\r\n Browsers:\r\n Chrome: 100.0.4896.75\r\n Chromium: 100.0.4896.60\r\n Firefox: 98.0.2\n```\n\n\n### Additional context\n\n_No response_\n\n### Validations\n\n- [X] Follow our [Code of Conduct](https://vuejs.org/about/coc.html)\n- [X] Read the [docs](https://vitepress.vuejs.org).\n- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.",[3113],{"name":3020,"color":3021},598,"Building with `mode: 'development'` throws errors, generates all pages as 404s","2023-01-21T16:04:31Z","https://github.com/vuejs/vitepress/issues/598",0.6627849,["Reactive",3120],{},["Set"],["ShallowReactive",3123],{"$fTRc1wZytZ_XrK4EfJfei_Sz-An4H4Yy6syhVxH_PVJc":-1,"$fTMWb4onPLbbEakmKdvfyQ7Wi0tCJaWU31nT01uH5vWQ":-1},"/vuejs/vitepress/2593"]