Three real bugs found and fixed while wiring up product images end-to-end: 1. src/prisma/migrate.ts only discovered flat prisma/migrations/<name>.sql files, never Prisma's own folder-per-migration layout (<timestamp>_<name>/migration.sql). Every migration created the normal way (via 'prisma migrate dev') was silently skipped; only a hand-added flat duplicate (prisma/migrations/0001_init.sql, now removed) ever ran. This meant schema.prisma had drifted well ahead of what any real deploy database actually had (missing columns on City, Customer, Branch, Product, several new tables). Fixed to discover both layouts; the drift is closed with a new 20260914165255_sync_schema_drift migration. 2. Neither nginx.conf (production) nor vite.config.ts (dev) proxied /uploads/ to the API — only /api/. UploadedFile/ProductImage URLs (/uploads/<file>, served by main.ts's useStaticAssets OUTSIDE the /api prefix) 404'd through both. Both now proxy /uploads/ the same way /api/ already was. 3. docker-compose.yml's api service had no volume for storage/uploads, so every uploaded file — and by extension every ProductImage row pointing at one — was lost on the next container recreate/redeploy. Added a named volume. Also: main.ts's static file serving now sets Content-Type: image/avif explicitly (serve-static's bundled mime table predates .avif and served it as application/octet-stream; browsers rendered it anyway by sniffing, but a stricter client would not have). Product photos: copied 15 real jewelry photos into the uploads volume, registered them as UploadedFile rows, and assigned each of the 5 existing Product rows a randomly picked one (duplicates allowed, per request), replacing their /img/no-items.png placeholder ProductImage row. Verified end-to-end in a real browser against the real containerized API+DB: logged in, opened the admin product list, confirmed all 5 rows render their photo (naturalWidth/Height populated, network 200s, no console errors). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
56 lines
2.2 KiB
TypeScript
56 lines
2.2 KiB
TypeScript
import { fileURLToPath, URL } from 'node:url';
|
|
import { defineConfig } from 'vite';
|
|
import vue from '@vitejs/plugin-vue';
|
|
|
|
// 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';
|
|
|
|
return {
|
|
// legacy: publicPath: isBranch ? '/branch/' : 'admin/'
|
|
base: isBranch ? '/branch/' : '/admin/',
|
|
plugins: [vue()],
|
|
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: {
|
|
port: 5174,
|
|
proxy: {
|
|
'/api': 'http://localhost:3000',
|
|
// 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:3000',
|
|
},
|
|
},
|
|
};
|
|
});
|