兼容低内核版本的浏览器
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import { jsxLocPlugin } from "@builder.io/vite-plugin-jsx-loc";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import path from "node:path";
|
||||
import { createRequire } from "node:module";
|
||||
import { defineConfig, type Plugin } from "vite";
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const tailwindcss3 = require("tailwindcss3");
|
||||
const autoprefixer = require("autoprefixer");
|
||||
|
||||
function legacyIndexRewritePlugin(): Plugin {
|
||||
return {
|
||||
name: "legacy-index-rewrite",
|
||||
apply: "serve",
|
||||
configureServer(server) {
|
||||
server.middlewares.use((req, _res, next) => {
|
||||
const url = req.url ?? "";
|
||||
if (url === "/" || url === "/index.html") {
|
||||
req.url = "/i.legacy.html";
|
||||
}
|
||||
next();
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [legacyIndexRewritePlugin(), react(), jsxLocPlugin()],
|
||||
define: {
|
||||
"import.meta.env.VITE_X9_LEGACY": JSON.stringify("1"),
|
||||
},
|
||||
base: process.env.NODE_ENV === "production" ? "/x9/v2/legacy/" : "/",
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(import.meta.dirname, "client", "src"),
|
||||
"@shared": path.resolve(import.meta.dirname, "shared"),
|
||||
"@assets": path.resolve(import.meta.dirname, "attached_assets"),
|
||||
},
|
||||
dedupe: ["react", "react-dom"],
|
||||
},
|
||||
envDir: path.resolve(import.meta.dirname),
|
||||
root: path.resolve(import.meta.dirname, "client"),
|
||||
publicDir: path.resolve(import.meta.dirname, "client/public"),
|
||||
css: {
|
||||
transformer: "postcss",
|
||||
postcss: {
|
||||
plugins: [tailwindcss3({ config: "./tailwind.legacy.config.cjs" }), autoprefixer()],
|
||||
},
|
||||
},
|
||||
build: {
|
||||
target: ["chrome91", "edge91"],
|
||||
cssTarget: "chrome91",
|
||||
outDir: path.resolve(import.meta.dirname, "dist/legacy"),
|
||||
emptyOutDir: true,
|
||||
minify: "terser",
|
||||
rollupOptions: {
|
||||
input: {
|
||||
i: path.resolve(import.meta.dirname, "client", "i.legacy.html"),
|
||||
},
|
||||
},
|
||||
},
|
||||
server: {
|
||||
port: 5173,
|
||||
strictPort: false,
|
||||
host: true,
|
||||
proxy: {
|
||||
"/luxsin-audio-api": {
|
||||
target: "https://api.luxsin.com.cn",
|
||||
changeOrigin: true,
|
||||
rewrite: (p) => p.replace(/^\/luxsin-audio-api/, "/audio"),
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user