【发布时间】:2022-01-16 00:19:39
【问题描述】:
我想在我的 typescript react 应用程序中使用绝对导入路径。
因此,我将"baseUrl": "./src" 添加到tsconfig.json。
我可以使用 yard build 在本地构建应用程序,但它不适用于 Github CI(操作)。
这是我从 CI 得到的错误
./src/components/App/App.tsx
Cannot find module: 'constants/Routes'. Make sure this package is installed.
我使用import { ROUTES } from 'constants/Routes' 导入组件。改用 ./constants/Routes 不适用于 set baseUrl。
我在使用.、src baseUrl 时遇到了同样的错误。
tsconfig.json
{
"compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"],
"module": "esnext",
"target": "es5",
"allowJs": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"jsx": "react",
"moduleResolution": "node",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"baseUrl": "./src"
},
"include": ["src"]
}
Action.yml
name: Deploy
on:
push:
branches: [main, feature/*]
pull_request:
branches: [main]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout ????️
uses: actions/checkout@v2.3.1
- name: Install and Build ????
run: |
yarn --frozen-lockfile
yarn build
- name: Deploy ????
uses: JamesIves/github-pages-deploy-action@4.1.5
with:
branch: gh-pages
folder: build
【问题讨论】:
标签: reactjs typescript github-pages github-actions