Skip to content

Commit 09895b2

Browse files
committed
refactor: enhance path resolution and add alias for improved readability
1 parent 297cf2e commit 09895b2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

e2e/local/dev/docs/.vitepress/config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { fileURLToPath } from 'node:url'
2+
import { resolve, dirname } from 'node:path'
23
import { defineConfig } from 'vitepress'
34
import { useSidebar } from 'vitepress-openapi'
45
import { testsPages } from '../../../../../docs/pages'
56
import spec from '../../../../../docs/public/openapi.json'
67

8+
const __filename = fileURLToPath(import.meta.url)
9+
const __dirname = dirname(__filename)
10+
const rootDir = resolve(__dirname, '../../../../../')
11+
712
const sidebar = useSidebar({
813
spec,
914
// Optionally, you can specify a link prefix for all generated sidebar items.
@@ -71,13 +76,14 @@ export default defineConfig({
7176
vite: {
7277
resolve: {
7378
alias: {
79+
'@': resolve(rootDir, 'src'),
80+
'@public': fileURLToPath(new URL('../../../../../docs/public', import.meta.url)),
7481
...(process.env.NODE_ENV === 'production'
7582
? {}
7683
: {
7784
'vitepress-openapi/client': fileURLToPath(new URL('../../../../../src/client', import.meta.url)),
7885
'vitepress-openapi/dist/style.css': fileURLToPath(new URL('../../../../../dist/vitepress-openapi.css', import.meta.url)),
7986
'vitepress-openapi': fileURLToPath(new URL('../../../../../src/index', import.meta.url)),
80-
'@public': fileURLToPath(new URL('../../../../../docs/public', import.meta.url)),
8187
}),
8288
},
8389
},

0 commit comments

Comments
 (0)