- Handler funkce extrahovany z API souboru do api/admin/handlers/ - config.php rozdeleny na helpers.php (funkce) a constants.php (konstanty) - require_once odstranen z class souboru (AuditLog, JWTAuth, LeaveNotification) - vendor/autoload.php presunuto do config.php bootstrap - totp-handlers.php: pridany use deklarace pro TwoFactorAuth - phpstan.neon: bootstrapFiles, scanDirectories, dynamicConstantNames - Opraveny chybejici routing bloky v totp.php a session.php Vysledek: phpcs 0 errors 0 warnings, PHPStan 0 errors, ESLint 0 errors Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
89 lines
2.5 KiB
JavaScript
89 lines
2.5 KiB
JavaScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import { copyFileSync, mkdirSync, readdirSync, existsSync, statSync } from 'fs'
|
|
import { execSync } from 'child_process'
|
|
import { resolve, join } from 'path'
|
|
|
|
function copyFolderSync(src, dest) {
|
|
mkdirSync(dest, { recursive: true })
|
|
const entries = readdirSync(src)
|
|
|
|
for (const entry of entries) {
|
|
const srcPath = join(src, entry)
|
|
const destPath = join(dest, entry)
|
|
|
|
if (statSync(srcPath).isDirectory()) {
|
|
copyFolderSync(srcPath, destPath)
|
|
} else {
|
|
copyFileSync(srcPath, destPath)
|
|
}
|
|
}
|
|
}
|
|
|
|
function copyFoldersPlugin() {
|
|
return {
|
|
name: 'copy-folders-plugin',
|
|
closeBundle() {
|
|
const outDir = resolve(__dirname, 'dist')
|
|
const apiSrc = resolve(__dirname, 'api')
|
|
const apiDest = resolve(outDir, 'api')
|
|
const vendorSrc = resolve(__dirname, 'vendor')
|
|
const vendorDest = resolve(outDir, 'vendor')
|
|
|
|
try {
|
|
if (existsSync(apiSrc)) {
|
|
copyFolderSync(apiSrc, apiDest)
|
|
console.log('✓ API folder copied to dist/api')
|
|
}
|
|
} catch (err) {
|
|
console.error('Error copying API folder:', err)
|
|
}
|
|
|
|
try {
|
|
if (existsSync(vendorSrc)) {
|
|
execSync('composer install --no-dev --quiet', { cwd: resolve(__dirname) })
|
|
copyFolderSync(vendorSrc, vendorDest)
|
|
execSync('composer install --quiet', { cwd: resolve(__dirname) })
|
|
console.log('✓ Vendor folder copied to dist/vendor (production only)')
|
|
}
|
|
} catch (err) {
|
|
console.error('Error copying vendor folder:', err)
|
|
execSync('composer install --quiet', { cwd: resolve(__dirname) })
|
|
}
|
|
|
|
console.log('✓ Build complete!')
|
|
}
|
|
}
|
|
}
|
|
|
|
export default defineConfig({
|
|
plugins: [react(), copyFoldersPlugin()],
|
|
build: {
|
|
outDir: 'dist',
|
|
emptyOutDir: true,
|
|
sourcemap: false,
|
|
target: 'es2020',
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks: {
|
|
'vendor-react': ['react', 'react-dom', 'react-router-dom'],
|
|
'vendor-animation': ['framer-motion'],
|
|
'vendor-utils': ['date-fns', 'dompurify']
|
|
}
|
|
}
|
|
}
|
|
},
|
|
server: {
|
|
port: 3000,
|
|
host: true,
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://localhost:8000',
|
|
changeOrigin: true,
|
|
secure: false,
|
|
cookieDomainRewrite: 'localhost',
|
|
cookiePathRewrite: '/'
|
|
}
|
|
}
|
|
}
|
|
}) |