compilerOptions.baseUrl
baseUrl表示以jsconfig.json为基础目录,当我配置如下时
{
"compilerOptions": {
"baseUrl": "./src"
}
}
project/
├── src/
│ ├── utils/
│ │ └── helper.js
│ └── index.js
└── jsconfig.json
import helper from 'utils/helper';
compilerOptions.paths
paths是基于baseUrl之上做细化的
{
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@utils/*": ["utils/*"],
"@components/*": ["components/*"]
}
}
}
import helper from '@utils/helper';
import Button from '@components/Button';