173 lines
4.5 KiB
TypeScript
173 lines
4.5 KiB
TypeScript
import { defineConfig } from "vite";
|
||
import react from "@vitejs/plugin-react";
|
||
import { VitePWA } from "vite-plugin-pwa";
|
||
|
||
// https://vitejs.dev/config/
|
||
export default defineConfig({
|
||
plugins: [
|
||
react(),
|
||
VitePWA({
|
||
injectRegister: "auto",
|
||
includeAssets: [
|
||
"icon.svg",
|
||
"icons/icon-192x192.png",
|
||
"icons/icon-512x512.png",
|
||
],
|
||
manifest: {
|
||
name: "NoteJS - Система заметок",
|
||
short_name: "NoteJS",
|
||
description:
|
||
"Современная система заметок с поддержкой Markdown, изображений, тегов и календаря",
|
||
theme_color: "#007bff",
|
||
background_color: "#ffffff",
|
||
display: "standalone",
|
||
orientation: "portrait-primary",
|
||
scope: "/",
|
||
start_url: "/",
|
||
icons: [
|
||
{
|
||
src: "/icons/icon-72x72.png",
|
||
sizes: "72x72",
|
||
type: "image/png",
|
||
purpose: "any",
|
||
},
|
||
{
|
||
src: "/icons/icon-96x96.png",
|
||
sizes: "96x96",
|
||
type: "image/png",
|
||
purpose: "any",
|
||
},
|
||
{
|
||
src: "/icons/icon-128x128.png",
|
||
sizes: "128x128",
|
||
type: "image/png",
|
||
purpose: "any",
|
||
},
|
||
{
|
||
src: "/icons/icon-144x144.png",
|
||
sizes: "144x144",
|
||
type: "image/png",
|
||
purpose: "any",
|
||
},
|
||
{
|
||
src: "/icons/icon-152x152.png",
|
||
sizes: "152x152",
|
||
type: "image/png",
|
||
purpose: "any",
|
||
},
|
||
{
|
||
src: "/icons/icon-192x192.png",
|
||
sizes: "192x192",
|
||
type: "image/png",
|
||
purpose: "any",
|
||
},
|
||
{
|
||
src: "/icons/icon-384x384.png",
|
||
sizes: "384x384",
|
||
type: "image/png",
|
||
purpose: "any",
|
||
},
|
||
{
|
||
src: "/icons/icon-512x512.png",
|
||
sizes: "512x512",
|
||
type: "image/png",
|
||
purpose: "any",
|
||
},
|
||
{
|
||
src: "/icons/icon-192x192.png",
|
||
sizes: "192x192",
|
||
type: "image/png",
|
||
purpose: "maskable",
|
||
},
|
||
{
|
||
src: "/icons/icon-512x512.png",
|
||
sizes: "512x512",
|
||
type: "image/png",
|
||
purpose: "maskable",
|
||
},
|
||
],
|
||
},
|
||
workbox: {
|
||
globPatterns: ["**/*.{js,css,html,ico,png,svg,woff,woff2,ttf,eot}"],
|
||
runtimeCaching: [
|
||
{
|
||
urlPattern: /^https:\/\/api\./,
|
||
handler: "NetworkFirst",
|
||
options: {
|
||
cacheName: "api-cache",
|
||
expiration: {
|
||
maxEntries: 50,
|
||
maxAgeSeconds: 60 * 60, // 1 hour
|
||
},
|
||
},
|
||
},
|
||
{
|
||
urlPattern: /\/api\//,
|
||
handler: "NetworkFirst",
|
||
options: {
|
||
cacheName: "api-cache-local",
|
||
expiration: {
|
||
maxEntries: 100,
|
||
maxAgeSeconds: 24 * 60 * 60, // 24 hours
|
||
},
|
||
networkTimeoutSeconds: 10,
|
||
},
|
||
},
|
||
{
|
||
urlPattern: /\/uploads\//,
|
||
handler: "CacheFirst",
|
||
options: {
|
||
cacheName: "uploads-cache",
|
||
expiration: {
|
||
maxEntries: 200,
|
||
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
|
||
},
|
||
},
|
||
},
|
||
{
|
||
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp)$/,
|
||
handler: "CacheFirst",
|
||
options: {
|
||
cacheName: "images-cache",
|
||
expiration: {
|
||
maxEntries: 100,
|
||
maxAgeSeconds: 30 * 24 * 60 * 60, // 30 days
|
||
},
|
||
},
|
||
},
|
||
],
|
||
cleanupOutdatedCaches: true,
|
||
skipWaiting: true,
|
||
clientsClaim: true,
|
||
},
|
||
registerType: "prompt",
|
||
devOptions: {
|
||
enabled: true,
|
||
type: "module",
|
||
},
|
||
}),
|
||
],
|
||
server: {
|
||
port: 5173,
|
||
allowedHosts: ["app.notejs.ru", "localhost"],
|
||
proxy: {
|
||
"/api": {
|
||
target: "http://localhost:3001",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
ws: true,
|
||
},
|
||
"/uploads": {
|
||
target: "http://localhost:3001",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
"/logout": {
|
||
target: "http://localhost:3001",
|
||
changeOrigin: true,
|
||
secure: false,
|
||
},
|
||
},
|
||
},
|
||
});
|