Files
tehran_taj/apps/user-app-v2/vite.config.ts
T
s.esmaeiliandClaude Haiku 5.5 532ceee189 feat: move brand name to one config and redesign the accounting card
اپ: نام برند در همه‌ی صفحه‌ها و پیام‌ها یکسان شده و از یک تنظیم مرکزی خوانده می‌شود.
اپ: کارت حسابداری در صفحه‌ی مشتری بازطراحی شد؛ مانده‌ها و وضعیت لینک واضح‌تر نمایش داده می‌شوند.
پنل: کارت حسابداری در پرونده‌ی مشتری بازطراحی شد؛ مانده‌ها، آخرین ارسال و فرم لینک دستی واضح‌تر شده‌اند.
پنل: ستون «کد» در جدول‌ها به‌طور پیش‌فرض پنهان است و از انتخاب ستون‌ها قابل نمایش است.
پنل: تغییر نمایش ستون‌ها در جدول‌ها بلافاصله اعمال می‌شود.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-14 13:31:20 +03:30

75 lines
2.7 KiB
TypeScript

import { fileURLToPath, URL } from 'node:url';
import { defineConfig, loadEnv } from 'vite';
import vue from '@vitejs/plugin-vue';
import { appVersion } from '../../scripts/app-version.mjs';
import { brand } from '../../brand';
import { VitePWA } from 'vite-plugin-pwa';
import { $themeLessVars } from './themeConfig/themeConfig';
import { lessAlphaPlugin, lightHex, palettePlugin } from './themeConfig/appearance';
// Ports are defined once in the repo-root .env (USER_APP_V2_PORT / API_PORT)
// — see that file's comment block.
const rootDir = fileURLToPath(new URL('../..', import.meta.url));
const rootEnv = loadEnv('development', rootDir, '');
const port = Number(rootEnv.USER_APP_V2_PORT ?? 5182);
const apiPort = Number(rootEnv.API_PORT ?? 3000);
export default defineConfig({
envDir: rootDir,
plugins: [
// Build number + «what changed» notes → version.json (scripts/app-version.mjs).
appVersion('user-app-v2'),
// <title> comes from the repo-root brand.ts, like every other brand text.
{ name: 'brand-title', transformIndexHtml: (html: string) => html.replace('%BRAND_TITLE%', brand.appTitle) },
vue(),
// virtual:palette.css — the light/dark values behind the theme tokens.
palettePlugin(),
// Ported from legacy vite.config.ts:18-52. Same injectManifest strategy,
// same src/sw.ts entry, same manifest values (name/colors/icons/display).
VitePWA({
base: '/',
srcDir: 'src',
filename: 'sw.ts',
strategies: 'injectManifest',
includeAssets: ['favicon.ico'],
// legacy ran the SW in dev too (mode: "development")
devOptions: { enabled: true, type: 'module' },
manifest: {
name: brand.appTitle,
short_name: brand.nameEn,
description: brand.appTitle,
theme_color: lightHex.primary,
background_color: lightHex.primary,
start_url: '/',
display: 'standalone',
icons: [
{ src: 'icon-192.png', sizes: '192x192', type: 'image/png' },
{ src: '/icon-512.png', sizes: '512x512', type: 'image/png' },
{ src: 'icon-512.png', sizes: '512x512', type: 'image/png', purpose: 'any maskable' },
],
},
}),
],
server: {
host: '0.0.0.0',
port,
// Never silently fall back to another port — fail loudly instead so a
// stuck dev server is obvious rather than moving to a random port.
strictPort: true,
proxy: {
'/api': `http://localhost:${apiPort}`,
'/uploads': `http://localhost:${apiPort}`,
},
},
css: {
preprocessorOptions: {
less: {
modifyVars: $themeLessVars,
javascriptEnabled: true,
// alpha(@token, N%) — fade() for theme tokens; see appearance.ts.
plugins: [lessAlphaPlugin],
},
},
},
});