2026-05-11 09:42:10 +00:00
|
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
|
import basicSsl from "@vitejs/plugin-basic-ssl";
|
|
|
|
|
|
import vue from "@vitejs/plugin-vue";
|
|
|
|
|
|
import { VitePWA } from "vite-plugin-pwa";
|
2026-05-11 10:23:29 +00:00
|
|
|
|
import {
|
|
|
|
|
|
copyFileSync,
|
|
|
|
|
|
mkdirSync,
|
|
|
|
|
|
writeFileSync,
|
|
|
|
|
|
readdirSync,
|
|
|
|
|
|
cpSync,
|
|
|
|
|
|
} from "node:fs";
|
|
|
|
|
|
|
|
|
|
|
|
const siteUrl = "https://explorer.kuraa.cc";
|
|
|
|
|
|
|
|
|
|
|
|
function generateStaticFiles() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
name: "generate-static-files",
|
|
|
|
|
|
closeBundle() {
|
|
|
|
|
|
const aboutDir = new URL("./dist/about/", import.meta.url);
|
|
|
|
|
|
mkdirSync(aboutDir, { recursive: true });
|
|
|
|
|
|
cpSync(
|
|
|
|
|
|
new URL("./static/", import.meta.url),
|
|
|
|
|
|
new URL("./dist/static/", import.meta.url),
|
|
|
|
|
|
{
|
|
|
|
|
|
recursive: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
const files = readdirSync(new URL("./readme/", import.meta.url));
|
|
|
|
|
|
files.forEach((file) => {
|
|
|
|
|
|
copyFileSync(
|
|
|
|
|
|
new URL(`./readme/${file}`, import.meta.url),
|
|
|
|
|
|
new URL(`./dist/about/${file}`, import.meta.url),
|
|
|
|
|
|
);
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const lastmod = new Date().toISOString().slice(0, 10);
|
|
|
|
|
|
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
|
|
|
|
|
<urlset xmlns="https://www.sitemaps.org/schemas/sitemap/0.9">
|
|
|
|
|
|
<url>
|
|
|
|
|
|
<loc>${siteUrl}/</loc>
|
|
|
|
|
|
<lastmod>${lastmod}</lastmod>
|
|
|
|
|
|
<changefreq>weekly</changefreq>
|
|
|
|
|
|
<priority>1.0</priority>
|
|
|
|
|
|
</url>
|
|
|
|
|
|
<url>
|
|
|
|
|
|
<loc>${siteUrl}/about/</loc>
|
|
|
|
|
|
<lastmod>${lastmod}</lastmod>
|
|
|
|
|
|
<changefreq>monthly</changefreq>
|
|
|
|
|
|
<priority>0.8</priority>
|
|
|
|
|
|
</url>
|
|
|
|
|
|
</urlset>
|
|
|
|
|
|
`;
|
|
|
|
|
|
const robots = `User-agent: *
|
|
|
|
|
|
Allow: /
|
|
|
|
|
|
|
|
|
|
|
|
Sitemap: ${siteUrl}/sitemap.xml
|
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
|
|
writeFileSync(new URL("./dist/sitemap.xml", import.meta.url), sitemap);
|
|
|
|
|
|
writeFileSync(new URL("./dist/robots.txt", import.meta.url), robots);
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-02 03:21:04 +00:00
|
|
|
|
// https://vitejs.dev/config/
|
|
|
|
|
|
export default defineConfig({
|
2026-05-11 09:42:10 +00:00
|
|
|
|
base: "./",
|
2025-01-02 03:21:04 +00:00
|
|
|
|
build: {
|
|
|
|
|
|
// 开发阶段启用源码映射:https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#需主动开启-sourcemap
|
2026-05-11 09:42:10 +00:00
|
|
|
|
sourcemap: process.env.NODE_ENV === "development",
|
2025-01-02 03:21:04 +00:00
|
|
|
|
},
|
2025-01-16 06:58:50 +00:00
|
|
|
|
plugins: [
|
|
|
|
|
|
vue(),
|
|
|
|
|
|
basicSsl(),
|
2026-05-11 10:23:29 +00:00
|
|
|
|
generateStaticFiles(),
|
2025-01-16 06:58:50 +00:00
|
|
|
|
VitePWA({
|
2026-05-11 09:42:10 +00:00
|
|
|
|
registerType: "autoUpdate",
|
2025-01-16 06:58:50 +00:00
|
|
|
|
manifest: {
|
2026-05-11 09:42:10 +00:00
|
|
|
|
name: "P2P Explorer",
|
|
|
|
|
|
short_name: "P2P Explorer",
|
|
|
|
|
|
description: "P2P文件传输与浏览工具",
|
|
|
|
|
|
theme_color: "#f5f5f5", //米色
|
|
|
|
|
|
background_color: "#f5f5f5",
|
2025-01-16 06:58:50 +00:00
|
|
|
|
icons: [
|
|
|
|
|
|
{
|
2026-05-11 09:42:10 +00:00
|
|
|
|
src: "/static/icon64.png",
|
|
|
|
|
|
sizes: "64x64",
|
|
|
|
|
|
type: "image/png",
|
2025-01-16 06:58:50 +00:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2026-05-11 09:42:10 +00:00
|
|
|
|
src: "/static/icon256.png",
|
|
|
|
|
|
sizes: "256x256",
|
|
|
|
|
|
type: "image/png",
|
|
|
|
|
|
},
|
|
|
|
|
|
],
|
2025-01-16 06:58:50 +00:00
|
|
|
|
},
|
|
|
|
|
|
workbox: {
|
2026-05-11 09:42:10 +00:00
|
|
|
|
globPatterns: ["**/*.{js,css,html,ico,png,svg,webp}"],
|
|
|
|
|
|
navigateFallbackDenylist: [/^\/about(?:\/|$)/],
|
|
|
|
|
|
runtimeCaching: [],
|
|
|
|
|
|
},
|
|
|
|
|
|
}),
|
2025-01-16 06:58:50 +00:00
|
|
|
|
],
|
2025-01-02 03:21:04 +00:00
|
|
|
|
server: {
|
2026-05-11 09:42:10 +00:00
|
|
|
|
host: "0.0.0.0",
|
2025-01-02 03:21:04 +00:00
|
|
|
|
},
|
2026-05-11 09:42:10 +00:00
|
|
|
|
});
|