vscode確實(shí)是比較好的編輯器
其中一個(gè)比較好的插件就是path autocomplete,但是這里有個(gè)問題唠亚,當(dāng)通過webpack的alias引用的時(shí)候,path autocomplete是不起作用的
import sss from "@common/"
然后后面也沒有路徑提示,自己手動(dòng)寫好他媽的煩
后來查了下废士,需要在項(xiàng)目跟路徑下配置一個(gè)jsconfig.json,讓vscode能夠識(shí)別出alias
廢話不多說,
webpack配置
resolve: {
alias: {
"@actions": `${this.srcPathAbsolute}/actions/`,
"@components": `${this.srcPathAbsolute}/components/`,
"@commonComp": `${this.srcPathAbsolute}/components/common/`,
"@common": `${this.srcPathAbsolute}/common/`
}
}
jsconfig.json的配置
{
"compilerOptions": {
"target": "es2017",
"allowSyntheticDefaultImports": false,
"baseUrl": "./",
"paths": {
"@actions/*": ["src/actions/*"],
"@components/*": ["src/components/"],
"@commonComp/*": ["src/components/common/"],
"@common/*": ["src/common/*"],
"@reducers/*": ["src/reducers/*"],
"@images/*": ["src/images/*"],
"@lib/*": ["src/lib/*"],
"@assets/*": ["src/assets/*"],
"@util/*": ["src/utility/*"],
"config/*": ["src/config/*"],
"sources/*": ["src/sources/*"],
"stores/*": ["src/stores/*"],
"styles/*": ["src/styles/*"]
}
},
"exclude": ["node_modules", "dist"],
"include": ["src"]
}
這樣在你引入路徑的時(shí)候蝇完,如果使用webpack的alias的時(shí)候官硝,就可以自動(dòng)提示路徑了