reactjs - 如何制作别名以指向外部文件夹?
问题描述
我有一个 React 项目,我想在其中使用一些别名来引用项目外部文件夹中的一些代码。这些文件夹没有 package.json 也没有 tsconfig.json,只有 .ts 文件。
这是我的 tsconfig.json:
{
"compilerOptions": {
"outDir": "./dist/", // path to output directory
"sourceMap": true, // allow sourcemap support
"strictNullChecks": true, // enable strict null checks as a best practice
"module": "esnext", // specify module code generation
"jsx": "react", // use typescript to transpile jsx to js
"target": "es5", // specify ECMAScript target version
"allowJs": true, // allow a partial TypeScript and JavaScript codebase
"baseUrl": ".",
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"paths": {
"@Root/*": ["./src/*"],
"@Common/*": ["./../common/*"],
"@Images/*": ["./../common/assets/images/*"],
}
},
"include" : ["./src/", "./../common/"],
"exclude": ["node_modules", "dist", "config", ".vscode"]
}
但是,每次我使用位于项目外部的“common”文件夹中的 @Common 或 @Images 引用某些内容时,我都会从 VSCode 中得到一个红色突出显示。
预先感谢您和问候
解决方案
推荐阅读
- javascript - bash: ./Main.js: Heroku 上的权限被拒绝
- java - Java 程序架构:IO 缓冲区
- sql - 获取错误--ORA-00936:MISSING EXPRESSION 用于以下查询,请对此提供帮助
- jquery - jquery-ajax-unobtrusive 是 .Net Core 的一部分吗
- vb.net - 如何同时下载多个网址?
- reactjs - React + REST API 中的一个错误
- python-3.x - 具有两个用户池的 Cognito 授权
- javascript - 使用延迟重置创建延迟搜索
- wxpython - 我可以调用 gridview.SetTable() 两次吗?
- python - 类型错误:ord() 预期长度为 1 的字符串,但 int 从图像中找到 bse64