让 VS 代码读取 webpack.config 并使用别名识别路径? [英] Make VS code read webpack.config and recognize path with alias?
问题描述
我正在使用 Webpack 和 Visual Studio Code,以避免出现以下情况:
I'm working with Webpack and Visual Studio Code and in order to avoid things like:
import { AuthenticationService } from '../../../services/authentication/service';
我在 webpack.config 上创建了别名,所以我可以使用:
I've created aliases on my webpack.config so I can use:
import { AuthenticationService } from 'services/authentication/service';
但是,这样做之后,Visual Code 无法检测到我的代码,因此我失去了类的智能感知.
However, by doing so Visual Code is not able to detected my code and therefore I lose the intelisense for my classes.
有没有人有解决方案,有没有办法让 VS 代码读取 webpack.config 并使用别名识别路径?
Does anyone have a solution for that, is there a way to make VS code to read the webpack.config and recognize the path with the alias?
提前致谢
推荐答案
update typescript@2.0.0,您可以通过添加以下内容在 tsconfig.json 上映射相同的 webpack 别名:
update typescript@2.0.0 and you can map the same webpack aliases on tsconfig.json by adding:
"compilerOptions": {
"baseUrl": "./",
"paths": {
"app/*": ["src/app/*"]
}
}
这篇关于让 VS 代码读取 webpack.config 并使用别名识别路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!