Skip to content

Commit

Permalink
updated env
Browse files Browse the repository at this point in the history
  • Loading branch information
Sivamani-18 committed Jul 24, 2024
1 parent 4b6611c commit 468d795
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_BASENAME=/vite-react-ts-boilerplate/
NODE_ENV=production
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ This project is a boilerplate setup using Vite, React, TypeScript, Tailwind CSS,
git clone https://github.com/Sivamani-18/vite-react-ts-boilerplate.git
cd vite-react-ts-boilerplate

App.tsx change basename "/vite-react-ts-boilerplate/" to "/" in local
```

2. Install dependencies:
Expand Down
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react-router-dom": "^6.25.1"
},
"devDependencies": {
"@types/node": "^20.14.12",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@typescript-eslint/eslint-plugin": "^7.15.0",
Expand Down
9 changes: 8 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@ import About from './pages/About';
import Header from './components/Header/Header';

function App() {
const basename =
process.env.NODE_ENV === 'production'
? process.env.REACT_APP_BASENAME
: '/';

console.log('basename', basename);

return (
<Router basename='/vite-react-ts-boilerplate/'>
<Router basename={basename}>
<div className='min-h-screen bg-background-light dark:bg-background-dark text-text-light dark:text-text-dark'>
<div className='mb-10'>
<Header />
Expand Down
5 changes: 4 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import react from '@vitejs/plugin-react';

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

0 comments on commit 468d795

Please sign in to comment.