Created
September 14, 2019 01:52
-
-
Save nbhaohao/29f7a6cb7c677078153628c8054c0bf9 to your computer and use it in GitHub Desktop.
webStorm/Idea 在 webpack 配置文件被隐藏的情况下,无法识别 alias 的问题
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const resolve = dir => require("path").join(__dirname, dir); | |
module.exports = { | |
resolve: { | |
alias: { | |
"@": resolve("src") | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TypeScript 可能也会有不能识别 alias 的问题,
需要在 tsconfig.json 中做配置:
{ "compilerOptions": { "baseUrl": "src", "paths": { "@/*": ["./*"] } }, "include": ["src"] }
jest 也会出现不能识别 alias 的问题
"moduleNameMapper": { "@/(.*)$": "<rootDir>/src/$1" },