memos/web/vite.config.ts

89 lines
2.0 KiB
TypeScript
Raw Normal View History

2023-09-17 14:20:03 +03:00
import react from "@vitejs/plugin-react-swc";
import { resolve } from "path";
2021-12-08 18:43:52 +03:00
import { defineConfig } from "vite";
import { VitePWA } from "vite-plugin-pwa";
2021-12-08 18:43:52 +03:00
let devProxyServer = "http://localhost:8081/";
if (process.env.DEV_PROXY_SERVER && process.env.DEV_PROXY_SERVER.length > 0) {
console.log("Use devProxyServer from environment: ", process.env.DEV_PROXY_SERVER);
devProxyServer = process.env.DEV_PROXY_SERVER;
}
2021-12-08 18:43:52 +03:00
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
VitePWA({
manifestFilename: "manifest.json",
registerType: "autoUpdate",
devOptions: {
enabled: true,
},
manifest: {
short_name: "memos",
2023-12-23 07:01:26 +03:00
name: "Memos",
description: "usememos/memos",
start_url: "/",
scope: "/",
display: "standalone",
theme_color: "#f4f4f5",
background_color: "#f4f4f5",
icons: [
{
src: "/logo.png",
type: "image/png",
sizes: "16x16",
},
{
src: "/logo.png",
type: "image/png",
sizes: "32x32",
},
{
src: "/logo.png",
sizes: "192x192",
type: "image/png",
},
{
src: "/logo.png",
sizes: "512x512",
type: "image/png",
purpose: "any maskable",
},
],
},
}),
],
2021-12-08 18:43:52 +03:00
server: {
2022-09-09 02:40:21 +03:00
host: "0.0.0.0",
2022-12-25 05:39:45 +03:00
port: 3001,
2021-12-08 18:43:52 +03:00
proxy: {
"^/api": {
target: devProxyServer,
xfwd: true,
2021-12-08 18:43:52 +03:00
},
2023-09-28 13:45:45 +03:00
"^/memos.api.v2": {
target: devProxyServer,
xfwd: true,
},
"^/o/": {
target: devProxyServer,
xfwd: true,
2022-09-09 02:40:21 +03:00
},
"^/u/.+/rss.xml": {
target: devProxyServer,
xfwd: true,
},
2023-09-18 17:34:31 +03:00
"^/explore/rss.xml": {
target: devProxyServer,
xfwd: true,
},
2021-12-08 18:43:52 +03:00
},
},
resolve: {
alias: {
"@/": `${resolve(__dirname, "src")}/`,
},
},
2021-12-08 18:43:52 +03:00
});