Skip to content

Commit

Permalink
support netlify
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed May 6, 2024
1 parent e00750b commit ffba8cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
21 changes: 19 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
name: test
on: [push, pull_request]
env:
CI: true
jobs:
test:
name: "Test on Node.js ${{ matrix.node-version }}"
Expand All @@ -21,3 +19,22 @@ jobs:
run: yarn install
- name: Test
run: yarn test

build:
name: "Build on Node.js ${{ matrix.node-version }}"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20 ]
steps:
- name: checkout
uses: actions/checkout@v4
- name: setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- name: Install
run: yarn install
- name: Test
run: yarn run build
13 changes: 10 additions & 3 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,16 @@ function setEnv(mode: string) {
Object.assign(process.env, loadEnv(mode, ".", ["REACT_APP_", "NODE_ENV", "PUBLIC_URL"]));
process.env.NODE_ENV ||= mode;
const { homepage } = JSON.parse(readFileSync("package.json", "utf-8"));
process.env.PUBLIC_URL ||= homepage
? `${homepage.startsWith("http") || homepage.startsWith("/") ? homepage : `/${homepage}`}`.replace(/\/$/, "")
: "";
if (process.env.DEPLOY_PRIME_URL) {
process.env.PUBLIC_URL ||= process.env.DEPLOY_PRIME_URL;
} else {
process.env.PUBLIC_URL ||= homepage
? `${homepage.startsWith("http") || homepage.startsWith("/") ? homepage : `/${homepage}`}`.replace(
/\/$/,
""
)
: "";
}
}

// Expose `process.env` environment variables to your client code
Expand Down

0 comments on commit ffba8cf

Please sign in to comment.