Skip to content

Commit

Permalink
Update Deploy to GitHub Pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Sivamani-18 committed Jul 24, 2024
1 parent 7281fb3 commit af5db21
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
1 change: 0 additions & 1 deletion .env → .env.production
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
REACT_APP_BASENAME=/vite-react-ts-boilerplate/
NODE_ENV=development
3 changes: 2 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ jobs:

- name: Build project
env:
REACT_APP_BASENAME: /vite-react-ts-boilerplate/
NODE_ENV: production
run: npm run build
run: npm run build:production

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"dev": "vite",
"build": "tsc -b && vite build",
"build:production": "vite build --mode production",
"build:production": "tsc -b && vite build --mode production",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
Expand Down
15 changes: 9 additions & 6 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
base:
process.env.NODE_ENV === 'production'
? process.env.REACT_APP_BASENAME
: '/',
plugins: [react()],
export default defineConfig(({ mode }) => {
if (mode === 'production') {
process.env.NODE_ENV = 'production';
}

return {
plugins: [react()],
base: process.env.REACT_APP_BASENAME || '/',
};
});

0 comments on commit af5db21

Please sign in to comment.