[英]How to add nested path aliases in vscode jsconfig?
我有這樣的配置:
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"common": ["./common/*"],
"components": ["./components/*"],
"services": ["./services/*"],
"styles": ["./styles/*"],
"state": ["./state/*"]
},
"lib": ["ES5"]
},
"include": ["./src/**/*"]
}
僅關注components
目錄,結構為:
components/shared/*
因此,要導入共享文件,我必須寫:
import File from "components/shared/file"
我應該如何修改 jsconfig 以便能夠直接從共享文件夾導入,例如:
import File from "shared/file"
然后你必須像這樣改變 json baseUrl
-
"baseUrl": "./src/components"
但這不是使用 baseUrl 的適當方式。 因為使用此設置后,您的所有導入都將根據components
文件夾進行。 這實際上不是基礎 url。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.