Dashboard — это static SPA, можно развернуть где угодно:
npm install -g vercel
vercel --prod
npm install -g netlify-cli
netlify deploy --prod --dir=dist
npm run build
# Скопируй dist/ в gh-pages branch
server {
listen 80;
server_name dashboard-new.szhub.space;
root /home/app/dashboard-new/dist;
index index.html;
# SPA routing
location / {
try_files $uri $uri/ /index.html;
}
# API proxy (если нужно)
location /api {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# Gzip compression
gzip on;
gzip_types text/css application/javascript application/json;
gzip_min_length 1000;
}
# 1. Build
cd /home/app/dashboard-new
npm run build
# 2. Создай nginx конфиг
sudo nano /etc/nginx/sites-available/dashboard-new
# 3. Symlink
sudo ln -s /etc/nginx/sites-available/dashboard-new /etc/nginx/sites-enabled/
# 4. Test & reload
sudo nginx -t
sudo systemctl reload nginx
sudo certbot --nginx -d dashboard-new.szhub.space
npm install -g serve
cd /home/app/dashboard-new
# Create PM2 ecosystem
cat > ecosystem.config.js << 'EOF'
module.exports = {
apps: [{
name: 'dashboard-new',
script: 'serve',
args: 'dist -l 5174',
cwd: '/home/app/dashboard-new',
instances: 1,
autorestart: true,
watch: false,
max_memory_restart: '200M',
env: {
NODE_ENV: 'production'
}
}]
};
EOF
pm2 start ecosystem.config.js
pm2 save
Убедись что .env содержит правильный API endpoint:
VITE_API_BASE=https://dashboard.szhub.space/api
.env.local для локальной разработки:
VITE_API_BASE=http://localhost:3000/api
// vite.config.ts
build: {
rollupOptions: {
output: {
manualChunks: {
'react-vendor': ['react', 'react-dom'],
'query': ['@tanstack/react-query'],
'charts': ['recharts'],
}
}
}
}
const KpiModal = lazy(() => import('./components/modals/KpiModal'));
npm run build
npm run preview
# Open http://localhost:5174
# Check if API is reachable
curl https://dashboard.szhub.space/api/health
# Expected: {"status":"ok","timestamp":"..."}
# .github/workflows/deploy.yml
name: Deploy Dashboard
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 22
- run: npm ci
- run: npm run build
- name: Deploy to Server
run: |
rsync -avz dist/ user@srv1321680:/home/app/dashboard-new/dist/
curl https://dashboard.szhub.space/api/health.env — правильный ли VITE_API_BASEpm2 status dashboard-backendpm2 logs dashboard-backendrm -rf node_modules && npm installnode -v (должна быть 22+)npm run type-checkLast Updated: 2026-02-25
Version: 1.0.0