天天看點

tsx配置alias在webstorm中無法識别問題

webpack配置檔案

resolve: {        extensions: ['.tsx', '.ts', '.js', '.less', '.json'],        alias: {            '@': resolve('../src'),        },    },      

一般情況下配置好這個後,在設定webpack配置檔案的位置就沒問題了,但在typeScript的tsx中無效。還需增加以下配置

"baseUrl": ".",        "paths": {            "@/*": ["./src/*"]        }      
{    "compilerOptions": {        "target": "esnext",        "module": "esnext",        "moduleResolution": "node",        "importHelpers": true,        "jsx": "react",        "esModuleInterop": true,        "sourceMap": true,        "experimentalDecorators": true,        "outDir": "lib",        "allowSyntheticDefaultImports": true,        "allowJs": true,        "emitDecoratorMetadata": true,        "baseUrl": ".",        "paths": {            "@/*": ["./src/*"]        }    },    "include": ["./package/**/*", "./types/**/*"]}