69 lines
1.5 KiB
TypeScript
69 lines
1.5 KiB
TypeScript
import { fileURLToPath } from "node:url";
|
|
import react from "@vitejs/plugin-react";
|
|
import { defineConfig, type Plugin } from "vite";
|
|
import { appConfig } from "./src/app.config";
|
|
|
|
function createHtmlConfigPlugin(): Plugin {
|
|
const viewport = [
|
|
`width=${appConfig.viewport.width}`,
|
|
`initial-scale=${appConfig.viewport.initialScale}`,
|
|
`minimum-scale=${appConfig.viewport.minimumScale}`,
|
|
`maximum-scale=${appConfig.viewport.maximumScale}`,
|
|
].join(", ");
|
|
|
|
return {
|
|
name: "html-config",
|
|
transformIndexHtml(html) {
|
|
return {
|
|
html: html
|
|
.replaceAll("%APP_TITLE%", appConfig.title)
|
|
.replaceAll("%APP_DESCRIPTION%", appConfig.description)
|
|
.replaceAll("%APP_FAVICON%", appConfig.favicon)
|
|
.replaceAll("%APP_VIEWPORT%", viewport),
|
|
tags: [
|
|
{
|
|
tag: "script",
|
|
attrs: {
|
|
src: "./videoajax/jquery-3.7.1.min.js",
|
|
},
|
|
injectTo: "head",
|
|
},
|
|
{
|
|
tag: "script",
|
|
attrs: {
|
|
src: "./videoajax/videoajax.js",
|
|
},
|
|
injectTo: "head",
|
|
},
|
|
],
|
|
};
|
|
},
|
|
};
|
|
}
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
base: "./",
|
|
plugins: [react(), createHtmlConfigPlugin()],
|
|
resolve: {
|
|
dedupe: ["react", "react-dom"],
|
|
alias: {
|
|
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
|
},
|
|
},
|
|
optimizeDeps: {
|
|
include: [
|
|
"react",
|
|
"react-dom",
|
|
"@dnd-kit/core",
|
|
"@dnd-kit/utilities",
|
|
"gsap",
|
|
"@gsap/react",
|
|
],
|
|
},
|
|
server: {
|
|
// 允许局域网设备访问,便于移动端真机调试;如不需要可改为 localhost。
|
|
host: true,
|
|
},
|
|
});
|