Skip to content

Commit

Permalink
feat: 支持 @ 路径别名
Browse files Browse the repository at this point in the history
  • Loading branch information
markthree committed Aug 2, 2023
1 parent 8bb19fc commit b7618c4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
18. 插件自动加载支持
19. Vitest 单元测试支持
20. 支持 Markdown 渲染
21. 路径别名 `~` 支持
21. 路径别名支持
22. 命令行自动创建与删除
23. i18n 国际化支持
24. 漂亮的 404 页 支持
Expand Down Expand Up @@ -898,9 +898,9 @@ pnpm coverage
<br />
<br />
### 21. 路径别名 `~` 支持
### 21. 路径别名支持
`~` 路径将被导向项目的 `src` 目录,同时有更好的类型提示
`~` 或者 `@` 路径将被导向项目的 `src` 目录,同时有更好的类型提示
```html
<!-- src/pages/index.vue -->
Expand Down
4 changes: 4 additions & 0 deletions presets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,10 @@ function Alias(): Plugin {
find: /^~/,
replacement: src,
},
{
find: /^@/,
replacement: src,
},
]
},
}
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"useDefineForClassFields": true,
"baseUrl": ".",
"paths": {
"~/*": ["src/*"]
"~/*": ["src/*"],
"@/*": ["src/*"],
}
},
"include": [
Expand Down

0 comments on commit b7618c4

Please sign in to comment.