gpt4 book ai didi

webpack - VScode : How to autocomple json/scss/image file paths from shortcut paths specified in jsconfig shortcuts

转载 作者:行者123 更新时间:2023-12-04 11:44:23 27 4
gpt4 key购买 nike

进行导入时,当我尝试导入 React .jsx 时,intellisense 会建议自动完成名称。成分。当我尝试导入 json 时不会有任何提示或 scss文件虽然。
我在 webpack.config.js 中设置了一组别名

  resolve: {
extensions: ['.css', '.js', '.jsx'],
alias: {
'src': path.resolve(__dirname + '/src'),
'data': path.resolve(__dirname + '/src/data'),
'assets': path.resolve(__dirname + '/src/assets'),
'images': path.resolve(__dirname + '/src/assets/images'),
'styles': path.resolve(__dirname + '/src/assets/styles'),
'components': path.resolve(__dirname + '/src/components'),
'types': path.resolve(__dirname + '/src/types'),
'functions': path.resolve(__dirname + '/src/functions'),
'pages': path.resolve(__dirname + '/src/pages')
}
},

因为我想让智能感知自动完成这些路径,所以我创建了一个 jsconfig.json

    {
"compilerOptions": {
"jsx": "react",
"allowSyntheticDefaultImports": true,
"target": "es6",
"baseUrl": "./",
"paths": {
"src": ["./src"],
"src/*": ["./src/*"],
"data": ["./src/data"],
"data/*": ["./src/data/*"],
"assets": ["./src/assets"],
"assets/*": ["./src/assets/*"],
"images": ["./src/assets/images"],
"images/*": ["./src/assets/images/*"],
"styles": ["./src/assets/styles"],
"styles/*": ["./src/assets/styles/*"],
"components": ["./src/components"],
"components/*": ["./src/components/*"],
"types": ["./src/types"],
"types/*": ["./src/types/*"],
"functions": ["./src/functions"],
"functions/*": ["./src/functions/*"],
"pages": ["./src/pages"],
"pages/*": ["./src/pages/*"],
}
},
"exclude": ["node_modules"],
"checkJs": "true"
}


我有 path intellisense已安装
我也有我的 keybindings.json设置为
[
{ "key": ".", "command": "" }
]
我还加了 "typescript.suggest.paths": false到我的 .vscode/setting.json正如路径智能感知文档中所建议的,尽管我是 不使用 typescript .这只是一个 javascript 项目。

最佳答案

我不得不添加

    "compilerOptions": {
"resolveJsonModule": true,
到我的 jsconfig.json for json

关于webpack - VScode : How to autocomple json/scss/image file paths from shortcut paths specified in jsconfig shortcuts,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64991572/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com