Files
frontend/vite.config.ts
T
ksv741 bb30935f73
Conventional commits / commits (pull_request) Successful in 30s
Frontend security / security (pull_request) Successful in 1m7s
Frontend verify / verify (pull_request) Successful in 4m48s
Frontend security / security (push) Successful in 11s
Frontend verify / verify (push) Successful in 6m17s
feat: add installable PWA #30
2026-09-20 19:55:53 +03:00

63 lines
1.8 KiB
TypeScript

import { fileURLToPath, URL } from "node:url";
import babel from "@rolldown/plugin-babel";
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
// https://vite.dev/config/
export default defineConfig({
plugins: [
react(),
babel({ presets: [reactCompilerPreset()] }),
VitePWA({
injectRegister: "script-defer",
// Let the waiting worker activate after all app windows close.
registerType: "prompt",
includeAssets: ["favicon.svg", "icons.svg", "apple-touch-icon.png"],
manifest: {
id: "/",
name: "WealthLedger",
short_name: "WealthLedger",
description: "Личные финансы и инвестиции",
lang: "ru",
start_url: "/",
scope: "/",
display: "standalone",
theme_color: "#ffffff",
background_color: "#ffffff",
icons: [
{ src: "/pwa-192x192.png", sizes: "192x192", type: "image/png" },
{ src: "/pwa-512x512.png", sizes: "512x512", type: "image/png" },
{
src: "/pwa-512x512.png",
sizes: "512x512",
type: "image/png",
purpose: "maskable",
},
],
},
workbox: {
globPatterns: ["**/*.{js,css,html,woff2}"],
// Only the static shell is cached; API requests always use the network.
navigateFallbackDenylist: [/^\/api(?:\/|$)/],
},
integration: {
configureOptions(config, options) {
// Storybook loads this Vite config but must not install an app worker.
options.disable = config.plugins.some((plugin) =>
plugin.name.startsWith("storybook:"),
);
},
},
}),
],
resolve: { alias: { "@": fileURLToPath(new URL("./src", import.meta.url)) } },
server: {
proxy: {
"/api/": {
target: process.env.API_PROXY_TARGET ?? "http://localhost:3000",
},
},
},
});