Skip to content

Commit

Permalink
feature: configure CI/CD
Browse files Browse the repository at this point in the history
  • Loading branch information
wilcorrea committed Apr 8, 2024
1 parent 5edb636 commit a88226b
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 16 deletions.
2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VITE_BASE_PATH=/quiz

VITE_SUPABASE_URL=https://<project>.supabase.co
VITE_SUPABASE_ANON_KEY=<your-anon-key>

Expand Down
7 changes: 7 additions & 0 deletions src/config/assets.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export function base (): string {
return import.meta.env.VITE_BASE_PATH || '/'
}

export function image (path: string): string {
return (base() + '/assets/images/' + path).replace(/([^:]\/)\/+/g, '$1')
}
16 changes: 9 additions & 7 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { BrowserRouter } from 'react-router-dom'
import './config/i18n'
import App from './App.tsx'
import './index.css'
import { base } from './config/assets.ts'

ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<BrowserRouter basename="/quiz">
<App />
</BrowserRouter>
</React.StrictMode>,
)
ReactDOM.createRoot(document.getElementById('root')!)
.render(
<React.StrictMode>
<BrowserRouter basename={base()}>
<App />
</BrowserRouter>
</React.StrictMode>,
)
3 changes: 2 additions & 1 deletion src/view/components/game/GameCorrectAnswer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { GameQuestionComponentsProps } from './GameQuestion.tsx'
import { image } from '../../../config/assets.ts'

export function GameCorrectAnswer ({ finishQuestion }: GameQuestionComponentsProps) {
return (
<div className="correct">
<img
style={{ width: '80%' }}
className="center-block"
src="/assets/images/phpinga.png"
src={image('/phpinga.png')}
alt="PHPinga"
/>
<h1 className="text-center">Certa a resposta!</h1>
Expand Down
3 changes: 2 additions & 1 deletion src/view/components/game/GameTimeExpired.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { GameQuestionComponentsProps } from './GameQuestion.tsx'
import { image } from '../../../config/assets.ts'

export function GameTimeExpired ({ finishQuestion }: GameQuestionComponentsProps) {
return (
<div className="wrong">
<img
style={{ width: '80%' }}
className="center-block"
src="/assets/images/phpinga.png"
src={image('/phpinga.png')}
alt="PHPinga"
/>
<h1 className="text-center">Acabou o tempo!</h1>
Expand Down
3 changes: 2 additions & 1 deletion src/view/components/game/GameWrongAnswer.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { GameQuestionComponentsProps } from './GameQuestion.tsx'
import { image } from '../../../config/assets.ts'

export function GameWrongAnswer ({ finishQuestion }: GameQuestionComponentsProps) {
return (
<div className="wrong">
<img
style={{ width: '80%' }}
className="center-block"
src="/assets/images/phpinga.png"
src={image('/phpinga.png')}
alt="PHPinga"
/>
<h1 className="text-center">Bebe!</h1>
Expand Down
3 changes: 2 additions & 1 deletion src/view/pages/game/GameEndPage.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useNavigate, useParams } from 'react-router-dom'
import { useTranslation } from 'react-i18next'
import { image } from '../../../config/assets.ts'

export function GameEndPage () {
const params = useParams()
Expand All @@ -16,7 +17,7 @@ export function GameEndPage () {
<img
style={{ width: '80%' }}
className="center-block"
src="/assets/images/phpinga.png"
src={image('/phpinga.png')}
alt="PHPinga"
/>
<h1 className="text-center">{t('title')}</h1>
Expand Down
14 changes: 9 additions & 5 deletions vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { defineConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
base: '/quiz',
})
export default ({ mode }: { mode: string}) => {
process.env = {...process.env, ...loadEnv(mode, process.cwd())}

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

0 comments on commit a88226b

Please sign in to comment.