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/**/*"]}