2026-09-18 12:54:45 +03:30
|
|
|
import { fileURLToPath, URL } from 'node:url';
|
|
|
|
|
import { defineConfig, loadEnv } from 'vite';
|
2026-09-09 06:46:27 +03:30
|
|
|
import vue from '@vitejs/plugin-vue';
|
2026-10-10 12:44:24 +03:30
|
|
|
import { appVersion } from '../../scripts/app-version.mjs';
|
2026-09-09 06:46:27 +03:30
|
|
|
import { VitePWA } from 'vite-plugin-pwa';
|
|
|
|
|
import { $themeLessVars } from './themeConfig/themeConfig';
|
2026-10-04 16:18:56 +03:30
|
|
|
import { lessAlphaPlugin, lightHex, palettePlugin } from './themeConfig/appearance';
|
2026-09-09 06:46:27 +03:30
|
|
|
|
2026-09-18 12:54:45 +03:30
|
|
|
// Ports are defined once in the repo-root .env (USER_APP_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_PORT ?? 5181);
|
|
|
|
|
const apiPort = Number(rootEnv.API_PORT ?? 3000);
|
|
|
|
|
|
2026-09-09 06:46:27 +03:30
|
|
|
export default defineConfig({
|
2026-09-18 12:54:45 +03:30
|
|
|
envDir: rootDir,
|
2026-09-09 06:46:27 +03:30
|
|
|
plugins: [
|
2026-10-10 12:44:24 +03:30
|
|
|
// Build number + «what changed» notes → version.json (scripts/app-version.mjs).
|
|
|
|
|
appVersion('user-app'),
|
2026-09-09 06:46:27 +03:30
|
|
|
vue(),
|
2026-10-04 16:18:56 +03:30
|
|
|
// virtual:palette.css — the light/dark values behind the theme tokens.
|
|
|
|
|
palettePlugin(),
|
2026-09-09 06:46:27 +03:30
|
|
|
// 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: {
|
2026-09-16 11:59:35 +03:30
|
|
|
name: 'Montzar',
|
|
|
|
|
short_name: 'Montzar',
|
|
|
|
|
description: 'Montzar',
|
2026-10-04 16:18:56 +03:30
|
|
|
theme_color: lightHex.primary,
|
|
|
|
|
background_color: lightHex.primary,
|
2026-09-09 06:46:27 +03:30
|
|
|
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: {
|
2026-09-16 01:15:16 +03:30
|
|
|
host: '0.0.0.0',
|
2026-09-18 12:54:45 +03:30
|
|
|
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,
|
2026-09-09 06:46:27 +03:30
|
|
|
proxy: {
|
2026-09-18 12:54:45 +03:30
|
|
|
'/api': `http://localhost:${apiPort}`,
|
|
|
|
|
'/uploads': `http://localhost:${apiPort}`,
|
2026-09-09 06:46:27 +03:30
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
css: {
|
|
|
|
|
preprocessorOptions: {
|
|
|
|
|
less: {
|
|
|
|
|
modifyVars: $themeLessVars,
|
|
|
|
|
javascriptEnabled: true,
|
2026-10-04 16:18:56 +03:30
|
|
|
// alpha(@token, N%) — fade() for theme tokens; see appearance.ts.
|
|
|
|
|
plugins: [lessAlphaPlugin],
|
2026-09-09 06:46:27 +03:30
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|