Skip to content

Instantly share code, notes, and snippets.

@nbhaohao
Created September 14, 2019 01:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbhaohao/29f7a6cb7c677078153628c8054c0bf9 to your computer and use it in GitHub Desktop.
Save nbhaohao/29f7a6cb7c677078153628c8054c0bf9 to your computer and use it in GitHub Desktop.
webStorm/Idea 在 webpack 配置文件被隐藏的情况下,无法识别 alias 的问题
const resolve = dir => require("path").join(__dirname, dir);
module.exports = {
resolve: {
alias: {
"@": resolve("src")
}
}
};
@nbhaohao
Copy link
Author

nbhaohao commented Sep 22, 2019

TypeScript 可能也会有不能识别 alias 的问题,
需要在 tsconfig.json 中做配置:
{ "compilerOptions": { "baseUrl": "src", "paths": { "@/*": ["./*"] } }, "include": ["src"] }
jest 也会出现不能识别 alias 的问题
"moduleNameMapper": { "@/(.*)$": "<rootDir>/src/$1" },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment