You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
2.0 KiB
TypeScript
78 lines
2.0 KiB
TypeScript
import {resolve} from "path";
|
|
|
|
import {defineConfig} from "vite";
|
|
import react from "@vitejs/plugin-react";
|
|
import svgr from "vite-plugin-svgr";
|
|
import {ViteEjsPlugin} from "vite-plugin-ejs";
|
|
import tsMonoAlias from "vite-plugin-ts-mono-alias";
|
|
|
|
const isOnline = !!process.env.VITE_IS_ONLINE;
|
|
console.log("isOnline", isOnline);
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
base: "/labelapp/",
|
|
publicDir: resolve(__dirname, "public"),
|
|
envDir: resolve(__dirname, "env"),
|
|
server: {
|
|
host: "0.0.0.0",
|
|
port: 3004,
|
|
// micro-app 跨域配置
|
|
cors: true,
|
|
headers: {
|
|
"Access-Control-Allow-Origin": "*",
|
|
},
|
|
proxy: {
|
|
"/databuilder": {
|
|
// target: "http://192.168.8.131:28080",
|
|
target: 'https://aistudio.ngsk.tech:7001/',
|
|
changeOrigin: true,
|
|
},
|
|
"/ws": {
|
|
target: "wss://labu.tech:8888/",
|
|
ws: true,
|
|
changeOrigin: true,
|
|
},
|
|
},
|
|
},
|
|
|
|
optimizeDeps: {
|
|
include: ["react/jsx-runtime"],
|
|
},
|
|
|
|
plugins: [
|
|
react(),
|
|
svgr(),
|
|
ViteEjsPlugin(),
|
|
!process.env.DIST && process.env.NODE_ENV !== "production" && tsMonoAlias(),
|
|
].filter(Boolean),
|
|
|
|
resolve: {
|
|
alias: {
|
|
"@": resolve(__dirname, "src/"),
|
|
},
|
|
},
|
|
|
|
build: {
|
|
outDir: "dist",
|
|
target: "es2015",
|
|
// micro-app 需要的配置
|
|
cssCodeSplit: false,
|
|
minify: "terser",
|
|
terserOptions: {
|
|
compress: {
|
|
drop_console: true,
|
|
drop_debugger: true,
|
|
},
|
|
},
|
|
rollupOptions: {
|
|
output: {
|
|
// 确保资源路径正确
|
|
assetFileNames: "assets/[name]-[hash][extname]",
|
|
chunkFileNames: "assets/[name]-[hash].js",
|
|
entryFileNames: "assets/[name]-[hash].js",
|
|
},
|
|
},
|
|
},
|
|
});
|