官方文档里面配置是
const { override, fixBabelImports, addLessLoader, addWebpackPlugin, addWebpackAlias } = require('customize-cra')
const path = require('path')
module.exports = override(
fixBabelImports('import', {
libraryName: 'antd',
libraryDirectory: 'es',
style: true,
}),
addWebpackAlias({
['@']: path.resolve(__dirname, './src'),
})
})
然后用的tsx,一直报错
Cannot find module '@'
头都大了
搞了很久,发现应该是我TS的基础有问题,因为刚接触
在根目录下新建 >paths.json
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"@/*": [
"*"
]
}
}
}
在tsconfig.json 加入
"extends": "./paths.json",
现在启动服务终于不报错了