added vite config

This commit is contained in:
2025-10-25 12:44:18 +02:00
parent 3856f93484
commit 8e782a5290
21 changed files with 1965 additions and 21900 deletions

View File

@@ -16,12 +16,22 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
outputs: outputs:
tag_name: ${{ steps.set_tag.outputs.tag_name }} tag_name: ${{ steps.set_tag.outputs.tag_name }}
is_main_branch: ${{ steps.branch_check.outputs.is_main }}
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 # Fetch all history for tags fetch-depth: 0 # Fetch all history for tags
- name: Check if main branch
id: branch_check
run: |
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/master" ]]; then
echo "is_main_branch=true" >> $GITHUB_OUTPUT
else
echo "is_main_branch=false" >> $GITHUB_OUTPUT
fi
- name: Determine next semantic version tag - name: Determine next semantic version tag
id: set_tag id: set_tag
run: | run: |
@@ -139,6 +149,8 @@ jobs:
type=sha type=sha
# Add the dynamically generated semantic version # Add the dynamically generated semantic version
${{ needs.set-tag.outputs.tag_name }} ${{ needs.set-tag.outputs.tag_name }}
# Add latest tag for main branch
${{ needs.set-tag.outputs.is_main_branch == 'true' && 'latest' }}
- name: Build and push Docker image - name: Build and push Docker image
uses: docker/build-push-action@v5 uses: docker/build-push-action@v5
@@ -168,3 +180,4 @@ jobs:
echo "- Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" echo "- Image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}"
echo "- Tags: ${{ steps.meta.outputs.tags }}" echo "- Tags: ${{ steps.meta.outputs.tags }}"
echo "- New version: ${{ needs.set-tag.outputs.tag_name }}" echo "- New version: ${{ needs.set-tag.outputs.tag_name }}"
echo "- Is main branch: ${{ needs.set-tag.outputs.is_main_branch }}"

23
.gitignore vendored
View File

@@ -114,4 +114,25 @@ Thumbs.db
# Ignore contents of premium folder in public repo # Ignore contents of premium folder in public repo
premium/* premium/*
!premium/README-PREMIUM.md !premium/README-PREMIUM.md
!premium/.gitkeep !premium/.gitkeep
.git
.gitignore
node_modules
npm-debug.log
README.md
.env
.nyc_output
coverage
.cache
dist
build
logs
*.tsbuildinfo
# Frontend specific
frontend/dist
frontend/.vite
# Backend specific
backend/dist

View File

@@ -29,7 +29,7 @@ RUN cp -r src/database/ dist/database/
# Verify Python and OR-Tools installation # Verify Python and OR-Tools installation
RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')" RUN python -c "from ortools.sat.python import cp_model; print('OR-Tools installed successfully')"
# Frontend build stage # Frontend build stage - UPDATED FOR VITE
FROM node:20-bullseye AS frontend-builder FROM node:20-bullseye AS frontend-builder
WORKDIR /app/frontend WORKDIR /app/frontend
@@ -37,15 +37,17 @@ WORKDIR /app/frontend
# Copy frontend files # Copy frontend files
COPY frontend/package*.json ./ COPY frontend/package*.json ./
COPY frontend/tsconfig.json ./ COPY frontend/tsconfig.json ./
COPY frontend/vite.config.ts ./
COPY frontend/index.html ./
# Install frontend dependencies # Install frontend dependencies
RUN npm install --legacy-peer-deps RUN npm ci
# Copy frontend source # Copy frontend source
COPY frontend/src/ ./src/ COPY frontend/src/ ./src/
COPY frontend/public/ ./public/ COPY frontend/public/ ./public/
# Build frontend # Build frontend with Vite
RUN npm run build RUN npm run build
# Production stage # Production stage
@@ -64,8 +66,8 @@ COPY --from=backend-builder /app/backend/package*.json ./
COPY --from=backend-builder /app/backend/dist/ ./dist/ COPY --from=backend-builder /app/backend/dist/ ./dist/
COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/ COPY --from=backend-builder /app/backend/node_modules/ ./node_modules/
# Copy frontend built files # Copy frontend built files - UPDATED FOR VITE (uses 'dist' instead of 'build')
COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/ COPY --from=frontend-builder /app/frontend/dist/ ./frontend-build/
# Copy PM2 configuration # Copy PM2 configuration
COPY ecosystem.config.cjs ./ COPY ecosystem.config.cjs ./

3893
backend/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ app.get('/api/health', (req: any, res: any) => {
}); });
// 🆕 STATIC FILE SERVING FÜR FRONTEND // 🆕 STATIC FILE SERVING FÜR FRONTEND
const frontendBuildPath = path.join(__dirname, '../frontend-build'); const frontendBuildPath = process.env.FRONTEND_BUILD_PATH || '../frontend-build';
console.log('📁 Frontend build path:', frontendBuildPath); console.log('📁 Frontend build path:', frontendBuildPath);
// Überprüfe ob das Verzeichnis existiert // Überprüfe ob das Verzeichnis existiert

View File

@@ -1,18 +1,17 @@
// ecosystem.config.cjs // ecosystem.config.cjs
module.exports = { module.exports = {
apps: [ apps: [{
{ name: 'schichtplan-app',
name: 'schichtplaner', script: './dist/server.js',
script: './dist/server.js', instances: 1,
instances: 1, env: {
exec_mode: 'fork', NODE_ENV: 'production',
env: { PORT: 3002,
NODE_ENV: 'production', FRONTEND_BUILD_PATH: './frontend-build'
PORT: 3002 },
}, error_file: './logs/err.log',
error_file: './logs/app-err.log', out_file: './logs/out.log',
out_file: './logs/app-out.log', log_file: './logs/combined.log',
time: true time: true
} }]
]
}; };

13
frontend/index.html Normal file
View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Shift Planning App</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

View File

@@ -4,44 +4,21 @@
"private": true, "private": true,
"type": "module", "type": "module",
"dependencies": { "dependencies": {
"@testing-library/dom": "^10.4.1", "react": "^19.0.0",
"@testing-library/jest-dom": "^6.9.1", "react-dom": "^19.0.0",
"@testing-library/react": "^16.3.0", "react-router-dom": "^6.28.0"
"@testing-library/user-event": "^13.5.0", },
"@types/jest": "^27.5.2", "devDependencies": {
"@types/node": "^16.18.126", "@types/react": "^19.0.0",
"@types/react": "^19.2.2", "@types/react-dom": "^19.0.0",
"@types/react-dom": "^19.2.1",
"@types/react-router-dom": "^5.3.3", "@types/react-router-dom": "^5.3.3",
"react": "^19.2.0", "@vitejs/plugin-react": "^4.3.3",
"react-dom": "^19.2.0", "typescript": "^5.7.3",
"react-router-dom": "^7.9.3", "vite": "^6.0.7"
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
}, },
"scripts": { "scripts": {
"start": "react-scripts start", "dev": "vite",
"build": "react-scripts build", "build": "tsc && vite build",
"test": "react-scripts test", "preview": "vite preview"
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
} }
} }

View File

@@ -1,4 +1,4 @@
// frontend/src/App.tsx - ONE-REPO SAFE WITHOUT DYNAMIC IMPORTS // src/App.tsx - UPDATED FOR VITE
import React from 'react'; import React from 'react';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import { AuthProvider, useAuth } from './contexts/AuthContext'; import { AuthProvider, useAuth } from './contexts/AuthContext';
@@ -22,8 +22,8 @@ import About from './components/Layout/FooterLinks/About/About';
import Features from './components/Layout/FooterLinks/Features/Features'; import Features from './components/Layout/FooterLinks/Features/Features';
import { CommunityContact, CommunityLegalPage } from './components/Layout/FooterLinks/CommunityLinks/communityLinks'; import { CommunityContact, CommunityLegalPage } from './components/Layout/FooterLinks/CommunityLinks/communityLinks';
// Feature flag from environment // Vite environment variables (use import.meta.env instead of process.env)
const ENABLE_PRO = process.env.ENABLE_PRO === 'true'; const ENABLE_PRO = import.meta.env.ENABLE_PRO === 'true';
// Conditional Premium Components // Conditional Premium Components
let PremiumContact: React.FC = CommunityContact; let PremiumContact: React.FC = CommunityContact;

View File

@@ -1,3 +1,14 @@
/* Reset and base styles */
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
#root {
min-height: 100vh;
}
body { body {
margin: 0; margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',

View File

@@ -1,19 +0,0 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);
// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();

10
frontend/src/main.tsx Normal file
View File

@@ -0,0 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)

View File

@@ -1 +0,0 @@
/// <reference types="react-scripts" />

View File

@@ -1,15 +0,0 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@@ -1,5 +0,0 @@
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';

12
frontend/src/vite-env.d.ts vendored Normal file
View File

@@ -0,0 +1,12 @@
/// <reference types="vite/client" />
// Define types for environment variables
interface ImportMetaEnv {
readonly VITE_APP_TITLE: string
readonly ENABLE_PRO: string
// more env variables...
}
interface ImportMeta {
readonly env: ImportMetaEnv
}

View File

@@ -1,28 +1,38 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es5", "target": "ES2020",
"lib": [ "useDefineForClassFields": true,
"dom", "lib": ["ES2020", "DOM", "DOM.Iterable"],
"dom.iterable", "module": "ESNext",
"esnext"
],
"allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"esModuleInterop": true, "ignoreDeprecations": "6.0",
"allowSyntheticDefaultImports": true,
"strict": true, /* Bundler mode */
"forceConsistentCasingInFileNames": true, "moduleResolution": "bundler",
"noFallthroughCasesInSwitch": true, "allowImportingTsExtensions": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true, "resolveJsonModule": true,
"isolatedModules": true, "isolatedModules": true,
"noEmit": true, "noEmit": true,
"ignoreDeprecations": "6.0",
"jsx": "react-jsx", "jsx": "react-jsx",
"downlevelIteration": true
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
/* Path mapping (modern approach) */
"paths": {
"@/*": ["./src/*"],
"@/components/*": ["./src/components/*"],
"@/pages/*": ["./src/pages/*"],
"@/contexts/*": ["./src/contexts/*"],
"@/utils/*": ["./src/utils/*"],
"@/services/*": ["./src/services/*"],
"@/models/*": ["./src/models/*"],
"@/design/*": ["./src/design/*"]
}
}, },
"include": [ "include": ["src"],
"src" "references": [{ "path": "./tsconfig.node.json" }]
] }
}

View File

@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}

38
frontend/vite.config.ts Normal file
View File

@@ -0,0 +1,38 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 3003,
host: true,
open: true
},
build: {
outDir: 'dist',
sourcemap: true,
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html')
}
}
},
resolve: {
alias: {
'@': resolve(__dirname, './src'),
'@/components': resolve(__dirname, './src/components'),
'@/pages': resolve(__dirname, './src/pages'),
'@/contexts': resolve(__dirname, './src/contexts'),
'@/models': resolve(__dirname, './src/models'),
'@/utils': resolve(__dirname, './src/utils'),
'@/services': resolve(__dirname, './src/services'),
'@/design': resolve(__dirname, './src/design')
}
},
// Define environment variables
define: {
'process.env': process.env
}
})

19640
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -7,15 +7,9 @@
"premium" "premium"
], ],
"scripts": { "scripts": {
"dev:frontend": "cd frontend && npm run dev", "docker:build": "docker build -t schichtplan-app .",
"dev:backend": "cd backend && npm run dev", "docker:run": "docker run -p 3002:3002 schichtplan-app",
"build:all": "npm run build:premium && npm run build:backend && npm run build:frontend", "build:all": "cd backend && npm run build && cd ../frontend && npm run build"
"build:premium": "cd premium && npm run build",
"build:backend": "cd backend && npm run build",
"build:frontend": "cd frontend && npm run build",
"type-check": "npm run type-check:all",
"type-check:all": "cd premium && npx tsc --noEmit && cd ../backend && npx tsc --noEmit && cd ../frontend && npx tsc --noEmit",
"clean": "rm -rf premium/dist backend/dist frontend/dist"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^5.3.3" "typescript": "^5.3.3"