Skip to content

Commit 328c68d

Browse files
committed
docs: add __dirname mention
1 parent 8592b1a commit 328c68d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

docs/guide/extending-routes.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,18 @@ You can extend the routes at build time with the `extendRoute` or the `beforeWri
77
```ts twoslash
88
import VueRouter from 'unplugin-vue-router/vite'
99
import path from 'node:path'
10-
const __dirname = '...'
10+
/**
11+
* In ESM environments, you can use `import.meta.url` to get the current file path:
12+
*
13+
* ```ts
14+
* import { dirname } from 'node:path'
15+
* import { fileURLToPath } from 'node:url'
16+
*
17+
* const __filename = fileURLToPath(import.meta.url)
18+
* const __dirname = dirname(__filename)
19+
* ```
20+
*/
21+
const __dirname: string = '...'
1122
// ---cut---
1223
// @moduleResolution: bundler
1324
VueRouter({

0 commit comments

Comments
 (0)