mirror of
https://github.com/labring/laf.git
synced 2026-01-25 16:07:45 +00:00
73 lines
1.8 KiB
TypeScript
73 lines
1.8 KiB
TypeScript
import react from "@vitejs/plugin-react-swc";
|
|
import path from "path";
|
|
import { defineConfig, loadEnv } from "vite";
|
|
import { VitePWA } from "vite-plugin-pwa";
|
|
import pluginRewriteAll from "vite-plugin-rewrite-all";
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig(({ command, mode }) => {
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
return {
|
|
server: {
|
|
port: 3001,
|
|
host: "0.0.0.0",
|
|
proxy: {
|
|
"/v1": {
|
|
target: env.VITE_DEV_SERVER_URL,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
plugins: [
|
|
react(),
|
|
pluginRewriteAll(),
|
|
VitePWA({
|
|
registerType: "autoUpdate",
|
|
includeAssets: ["favicon.ico", "apple-touch-icon.png", "masked-icon.png"],
|
|
devOptions: {
|
|
enabled: false,
|
|
},
|
|
workbox: {
|
|
globPatterns: ["**/*.{js,css,html,png,svg,json}"],
|
|
navigateFallbackDenylist: [/^\/v1/],
|
|
},
|
|
manifest: {
|
|
name: "laf",
|
|
short_name: "Laf",
|
|
description: "life is short, you need laf:)",
|
|
theme_color: "#eef0f2",
|
|
icons: [
|
|
{
|
|
src: "pwa-192x192.png",
|
|
sizes: "192x192",
|
|
type: "image/png",
|
|
},
|
|
{
|
|
src: "pwa-512x512.png",
|
|
sizes: "512x512",
|
|
type: "image/png",
|
|
},
|
|
],
|
|
},
|
|
}),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
"@": path.resolve(__dirname, "./src"),
|
|
},
|
|
},
|
|
build: {
|
|
sourcemap: true,
|
|
rollupOptions: {
|
|
output: {
|
|
manualChunks(id) {
|
|
if (id.includes("node_modules")) {
|
|
return id.toString().split("node_modules/")[1].split("/")[0].toString();
|
|
}
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|