diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d06f6e3..d6e45d7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,6 +13,8 @@ jobs: env: REACT_APP_PUBLIC_PATH: /webpack5-react-template/ REACT_APP_MSW_ENABLE: true + REACT_APP_API_BASE_URL: / + REACT_APP_ENV: prod steps: - name: Checkout @@ -24,7 +26,9 @@ jobs: node-version: 20 - name: Set Environment Variables - run: echo "REACT_APP_PUBLIC_PATH=${{ env.REACT_APP_PUBLIC_PATH }}" >> $GITHUB_ENV + run: + echo "REACT_APP_PUBLIC_PATH=${{ env.REACT_APP_PUBLIC_PATH }}" >> + $GITHUB_ENV - uses: pnpm/action-setup@v2 name: Install pnpm @@ -48,8 +52,8 @@ jobs: - name: Install dependencies run: pnpm install -# - name: Run Tests -# run: pnpm run test --onlyChanged + # - name: Run Tests + # run: pnpm run test --onlyChanged - name: Build run: pnpm run build diff --git a/webpack/webpack.common.ts b/webpack/webpack.common.ts index a933013..94e7bcb 100644 --- a/webpack/webpack.common.ts +++ b/webpack/webpack.common.ts @@ -145,6 +145,7 @@ const config: Configuration = { // basic: false, // 默认true,启用一个简单的日志报告器 // profile: false, // 默认false,启用探查器。 }), + // todo, 如果使用的某一个process.env.REACT_APP_XX,没有配置,则不会替换,会报错的 new DefinePlugin( Object.keys(process.env) .filter((key) => key.startsWith(ENV_PREFIX))