Fix #334 Vite run lower version

This commit is contained in:
Karthikalakshmi 2026-04-01 17:59:05 +05:30
parent 0d570f6c9e
commit 1a7870a9ed
2 changed files with 56 additions and 17 deletions

View File

@ -31,7 +31,6 @@
"@tanstack/react-query-devtools": "^5.91.1", "@tanstack/react-query-devtools": "^5.91.1",
"@tanstack/react-virtual": "^3.13.18", "@tanstack/react-virtual": "^3.13.18",
"@types/node": "^25.5.0", "@types/node": "^25.5.0",
"@vitejs/plugin-legacy": "^8.0.1",
"@zxing/library": "^0.21.3", "@zxing/library": "^0.21.3",
"antd": "^5.17.4", "antd": "^5.17.4",
"antd-img-crop": "^4.22.0", "antd-img-crop": "^4.22.0",
@ -90,6 +89,7 @@
"devDependencies": { "devDependencies": {
"@types/react": "^18.3.3", "@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0", "@types/react-dom": "^18.3.0",
"@vitejs/plugin-legacy": "^8.0.0",
"@vitejs/plugin-react": "^6.0.1", "@vitejs/plugin-react": "^6.0.1",
"esbuild": "^0.27.4", "esbuild": "^0.27.4",
"eslint": "^8.57.0", "eslint": "^8.57.0",
@ -98,7 +98,7 @@
"eslint-plugin-react-refresh": "^0.4.7", "eslint-plugin-react-refresh": "^0.4.7",
"prettier": "^3.5.3", "prettier": "^3.5.3",
"rollup-plugin-obfuscator": "^1.1.0", "rollup-plugin-obfuscator": "^1.1.0",
"sass": "^1.98.0", "sass": "^1.77.2",
"terser": "^5.31.3", "terser": "^5.31.3",
"vite": "^8.0.0", "vite": "^8.0.0",
"vite-plugin-obfuscator": "^1.0.5", "vite-plugin-obfuscator": "^1.0.5",

View File

@ -1,27 +1,66 @@
import { defineConfig } from "vite"; import { defineConfig } from 'vite';
import react from "@vitejs/plugin-react"; import react from '@vitejs/plugin-react';
import legacy from '@vitejs/plugin-legacy';
import esbuild from 'esbuild';
export default defineConfig(({ mode }) => { export default defineConfig(({ mode }) => {
const isProd = mode === "production"; const isProd = mode === 'production';
return { return {
plugins: [react()], oxc: {
target: 'es2015'
},
plugins: [
react(),
legacy({
targets: [
"defaults",
"Android >= 5",
"Chrome >= 60"
],
}),
{
name: 'downlevel-dev',
enforce: 'post',
async transform(code, id) {
if (mode === 'development' && /\.(mjs|js|ts|jsx|tsx)(?:[?#]|$)/.test(id)) {
try {
const res = await esbuild.transform(code, { target: 'chrome64', loader: 'jsx' });
return res.code;
} catch (e) {
return code;
}
}
}
}
],
base: isProd ? "/apps/retail/" : "/", //for capcitor base: isProd ? "/" : "/", base: '/',
envDir: 'src',
envPrefix: 'ENV_',
envDir: "src", server: {
envPrefix: "ENV_", host: '0.0.0.0',
port: process.env.PORT || 3015,
server: { hmr: {
host: true, // 🔥 auto detect your IP host: '192.168.1.35',
port: process.env.PORT || 3015, port: 3015,
protocol: 'ws',
clientPort: 3015,
}
},
optimizeDeps: {
include: ['jspdf'],
}, },
build: { build: {
minify: "esbuild", target: 'es2015',
minify: 'esbuild',
esbuild: { esbuild: {
drop: isProd ? ["console", "debugger"] : [], drop: isProd ? ['console', 'debugger'] : [],
}, },
}, },
}; };
}); });