两者都可以设置路径别名,我下了个demo,两者都用了,为什么不能只用其中一个呢?
.babelrc(babel-plugin-module-resolver)
[
"module-resolver",
{
"root": ["./"],
"alias": {
"@Common": "./common",
"@Components": "./components",
"@Server": "./server"
}
}
]
tsconfig.json(tsconfig-paths)
"baseUrl": "./",
"paths": {
"@Common/*": ["./common/*"],
"@Components/*": ["./components/*"],
"@Server/*": ["./server/*"]
}
从名字就能看出来了啊……一个是 babel 插件,一个是 typescript 插件。
一般来说都还是配合 Webpack 使用。