gpt4 book ai didi

javascript - 带有 express js 的 babel :avoid relative path imports

转载 作者:行者123 更新时间:2023-11-29 20:55:59 26 4
gpt4 key购买 nike

目前我的导入是这样的

 import router from '../../app/routes'

有什么办法可以避免这个 ../../ 例如:import router from 'app/routes' in typescript 我可以这样做

{
"@app/*":["app/*"]
}

Babel 中有相同的东西吗??

最佳答案

是的,您可以使用 babel-plugin-module-resolver

"plugins": [
["module-resolver", {
"root": ["./src"],
"alias": {
"app": "./app",
},
}]
]

例如,将所有对“app”的引用别名为./src/app

关于javascript - 带有 express js 的 babel :avoid relative path imports,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49334893/

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