diff --git a/package.json b/package.json index 4b811ff0..4fd80d28 100644 --- a/package.json +++ b/package.json @@ -88,7 +88,7 @@ "prismjs": "^1.20.0", "sirv": "^1.0.10", "slash": "^3.0.0", - "vite": "^2.0.0-beta.6", + "vite": "^2.0.0-beta.7", "vue": "^3.0.5" }, "devDependencies": { diff --git a/src/client/app/composables/head.ts b/src/client/app/composables/head.ts index 1230760a..fc55fca6 100644 --- a/src/client/app/composables/head.ts +++ b/src/client/app/composables/head.ts @@ -7,7 +7,7 @@ export function useUpdateHead(route: Route, siteDataByRouteRef: Ref) { let isFirstUpdate = true const updateHeadTags = (newTags: HeadConfig[]) => { - if (process.env.NODE_ENV === 'production' && isFirstUpdate) { + if (import.meta.env.PROD && isFirstUpdate) { // in production, the initial meta tags are already pre-rendered so we // skip the first update. isFirstUpdate = false diff --git a/src/client/app/index.ts b/src/client/app/index.ts index d450d859..ea308300 100644 --- a/src/client/app/index.ts +++ b/src/client/app/index.ts @@ -54,7 +54,7 @@ export function createApp() { } function newApp(): App { - return process.env.NODE_ENV === 'production' + return import.meta.env.PROD ? createSSRApp(VitePressApp) : createClientApp(VitePressApp) } @@ -85,6 +85,7 @@ function newRouter(): Router { } // SSR: sync require + // @ts-ignore return require(pageFilePath) }, NotFound) } diff --git a/src/client/app/mixin.ts b/src/client/app/mixin.ts index 9fb29376..24841ce8 100644 --- a/src/client/app/mixin.ts +++ b/src/client/app/mixin.ts @@ -65,13 +65,11 @@ export function mixinGlobalComputed( } export function mixinGlobalComponents(app: App) { - const isProd = process.env.NODE_ENV === 'production' - app.component('Content', Content) app.component('ClientOnly', ClientOnly) app.component( 'Debug', - isProd + import.meta.env.PROD ? () => null : defineAsyncComponent(() => import('./components/Debug.vue')) ) diff --git a/src/client/env.d.ts b/src/client/env.d.ts deleted file mode 100644 index a8708975..00000000 --- a/src/client/env.d.ts +++ /dev/null @@ -1 +0,0 @@ -import 'vite/env' diff --git a/src/client/theme-default/composables/activeSidebarLink.ts b/src/client/theme-default/composables/activeSidebarLink.ts index 278e17c2..1b3b1d01 100644 --- a/src/client/theme-default/composables/activeSidebarLink.ts +++ b/src/client/theme-default/composables/activeSidebarLink.ts @@ -113,7 +113,7 @@ function isAnchorActive( } function throttleAndDebounce(fn: () => void, delay: number): () => void { - let timeout: NodeJS.Timeout + let timeout: number let called = false return () => { diff --git a/src/client/tsconfig.json b/src/client/tsconfig.json index 08160422..6182a129 100644 --- a/src/client/tsconfig.json +++ b/src/client/tsconfig.json @@ -6,7 +6,7 @@ "target": "esnext", "module": "esnext", "lib": ["ESNext", "DOM"], - "types": ["vite"], + "types": ["vite/client"], "paths": { "/@shared/*": ["shared/*"], "/@types/*": ["../../types/*"], diff --git a/yarn.lock b/yarn.lock index ef4f6292..4daa5367 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6031,10 +6031,10 @@ verror@1.10.0: core-util-is "1.0.2" extsprintf "^1.2.0" -vite@^2.0.0-beta.6: - version "2.0.0-beta.6" - resolved "https://registry.yarnpkg.com/vite/-/vite-2.0.0-beta.6.tgz#8f62e05027b0dbbcc9640c7e641b1f9a39310b62" - integrity sha512-VtzB5X5XUUNWBTnOrdsi6pqBj7V/95kJ2GmcVTdfnnmN1KzShEW2NH1e210adXiuuPn4wtGShg4ruIuq02Evzg== +vite@^2.0.0-beta.7: + version "2.0.0-beta.7" + resolved "https://registry.yarnpkg.com/vite/-/vite-2.0.0-beta.7.tgz#8200198ac3c0a5e9deb62579e01053cea89d6176" + integrity sha512-9tkmaq4PbBDWmcvIto07jpkMiD084EgDsizZxijYrpS3ojC9myksA/hlKA7RzK+uSEFetcb1ZY4ONpJQb/J+vw== dependencies: esbuild "^0.8.26" postcss "^8.2.1"