create-react-app typescript 配置路径别名

webpack 新增如下配置

resolve:{
      alias: {
        ......
        '@':path.resolve(__dirname,'../src'),
        '@com':path.resolve(__dirname,'../src/component'),
      },
}

tsconfig.json 新增如下配置

  "compilerOptions": {
    .......
    "baseUrl": "src",
    "paths": {
      "@/*": ["*"],
      "@com/*": ["component/*"]
    }
}

你可能感兴趣的:(create-react-app typescript 配置路径别名)