- The build number is the commit count, so every build raises it with no file to bump. scripts/app-version.mjs bakes it into each front-end (__APP_BUILD__) and writes dist/version.json with that app's notes. - Notes come from commit messages: only Persian lines that start with one of the four app tags are shown, each to its own app (docs/RELEASE-NOTES.md). - Both customer apps and the admin panel poll version.json (every 5 minutes and on return to the tab, bypassing caches). A newer build opens a modal that cannot be dismissed. «بهروزرسانی» unregisters the service worker, empties Cache Storage and reloads; localStorage (sign-in, cart, settings) is kept. - Replaces legacy's version dialog, which compared against a package.json version that was never bumped and so never opened, and useRefresh, which swapped in a new service worker silently. - nginx (all three apps and nginx-spa.conf): index.html, sw.js and version.json are never cached. sw.js used to fall under the 6-month rule, which could pin a browser to an old release. Checked: served with the real nginx config, a newer version.json opens the modal with its notes; the same build does not. اپ: اجرت هر کالا حالا همان است که در فاکتور حساب میشود؛ درصد خود شما و تخفیفها هم در آن آمده است. اپ: علاقهمندیهای شما ذخیره میشوند و در هر دستگاهی که وارد شوید دیده میشوند. اپ: از این به بعد هر نسخهی تازه با فهرست تغییراتش اعلام میشود. پنل: بخش تازهی «اجرت»: فرمول اجرت را با یک نمونه امتحان و بعد تأیید کنید. پنل: شهرها مثل قبل بهصورت درختاند (کشور، استان، شهر، محله)؛ شهری که درصد ندارد درصد شهر بالاتر را میگیرد. پنل: «تاریخ تولد» به فرم مشتری عمده و تکی برگشت. پنل: در گزارش تجمیعی سفارشها، دکمهی «دریافت فایل اکسل» اضافه شد. پنل: رد احراز هویت مشتری حالا دلیل هم میگیرد. پنل: با تأیید یا رد سند مالی، به مشتری پیامک میرود؛ در پیامک گروهی، %name با نام مشتری عوض میشود. پنل: از این به بعد هر نسخهی تازهی پنل با فهرست تغییراتش اعلام میشود. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
3.3 KiB
TypeScript
73 lines
3.3 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';
|
|
|
|
// Ported from legacy henza_admin/vue.config.js.
|
|
// The legacy build switched publicPath/outputDir on NODE_ENV=='branch'; in Vite the
|
|
// equivalent switch is the --mode flag (`pnpm dev:branch` / `pnpm build:branch`),
|
|
// which src/utils/index.ts reads via import.meta.env.MODE.
|
|
export default defineConfig(({ mode }) => {
|
|
const isBranch = mode === 'branch';
|
|
// Ports are defined once in the repo-root .env (ADMIN_PANEL_PORT / API_PORT)
|
|
// — see that file's comment block. envDir points here so `vite` picks it up
|
|
// even though this app's own directory has no .env of its own.
|
|
const rootEnv = loadEnv(mode, fileURLToPath(new URL('../..', import.meta.url)), '');
|
|
const port = Number(rootEnv.ADMIN_PANEL_PORT ?? 5180);
|
|
const apiPort = Number(rootEnv.API_PORT ?? 3000);
|
|
|
|
return {
|
|
envDir: fileURLToPath(new URL('../..', import.meta.url)),
|
|
// Admin is served on its own subdomain (e.g. adm.bnk…), so assets must be
|
|
// rooted at `/`. Legacy used publicPath `admin/` because it shared a host
|
|
// path; keeping that here made index.html request `/admin/assets/…` while
|
|
// the image only has `/assets/…` → white screen 404.
|
|
// Branch mode still mounts under `/branch/` when that mode is used.
|
|
base: isBranch ? '/branch/' : '/',
|
|
// Build number + «what changed» notes → version.json (scripts/app-version.mjs).
|
|
plugins: [vue(), appVersion('admin-panel')],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
|
},
|
|
},
|
|
css: {
|
|
preprocessorOptions: {
|
|
less: {
|
|
// ant-design-vue 4 dropped LESS theming (modifyVars) for CSS-in-JS design
|
|
// tokens; the equivalent primary/link/radius tokens now live in
|
|
// App.vue's <a-config-provider :theme>. This block only compiles the
|
|
// app's own farsi.less/utilities.less, which have no LESS variables.
|
|
javascriptEnabled: true,
|
|
},
|
|
},
|
|
},
|
|
build: {
|
|
// Legacy's vue.config.js used outputDir 'dist/export' / 'branchDist/export',
|
|
// but this app's Dockerfile does `COPY dist /usr/share/nginx/html` and nginx
|
|
// serves that folder's ROOT. With the build landing in dist/export/, the
|
|
// root kept whatever index.html was committed there before — a stale
|
|
// pre-port build — so the deployed panel served that instead of this app.
|
|
// Build straight into the folder the image actually serves (which is also
|
|
// what apps/user-app does).
|
|
outDir: isBranch ? 'branchDist' : 'dist',
|
|
emptyOutDir: true,
|
|
sourcemap: false, // legacy: productionSourceMap: false
|
|
},
|
|
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}`,
|
|
// Uploaded files (ProductImage.url etc.) are served by the API's own
|
|
// static handler, not this dev server — without this they 404 in dev
|
|
// even though production nginx (nginx.conf) already proxies them.
|
|
'/uploads': `http://localhost:${apiPort}`,
|
|
},
|
|
},
|
|
};
|
|
});
|