From 50ee7232f3c98fe24a1f2e31dba9508cfec14887 Mon Sep 17 00:00:00 2001
From: gjj <Ganjj@probim.com.cn>
Date: Fri, 21 Feb 2025 17:35:39 +0800
Subject: [PATCH] 模型预览

---
 vite.config.js |   98 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 98 insertions(+), 0 deletions(-)

diff --git a/vite.config.js b/vite.config.js
new file mode 100644
index 0000000..037f13a
--- /dev/null
+++ b/vite.config.js
@@ -0,0 +1,98 @@
+/* eslint-disable no-unused-vars */
+import path from "path";
+import { defineConfig, splitVendorChunkPlugin } from "vite";
+// splitVendorChunk, isCSSRequest
+
+import PluginForViteVue2 from "@vitejs/plugin-vue2";
+
+export default defineConfig(({ mode }) => {
+    return {
+        resolve: {
+            alias: {
+                "@": path.resolve(__dirname, './src'),
+                "@css": path.resolve("./src/assets/css"),
+                'worker-loader': require.resolve('worker-loader'),
+            },
+        },
+        worker: {
+            // 例如,设置一个worker的入口文件
+            // 注意:这是一个假设的配置,具体取决于worker-loader是否支持这样的配置
+            // entry: '/path/to/worker/entry.js',
+            options: { inline: true, name: 'workerName.[hash].js' }
+        },
+        plugins: [PluginForViteVue2(), splitVendorChunkPlugin()],
+        css: {
+            preprocessorOptions: {
+                scss: {
+                    additionalData: "@import '@css/sass.scss';",
+                },
+            },
+        },
+        server: {
+            proxy: {
+                "^/api/": {
+                    // target: "http://47.117.124.20:2002/",
+                    target: "https://www.probim.cn:7707",
+                    rewrite: (path) => path.replace(/^\/api\//, ""),
+                    changeOrigin: true, //通过浏览器查看像是"未生效",实际发送给后端的是更改过的Host(与target的host相同)
+                },
+            },
+            port: 3000,
+            host: "0.0.0.0",
+            cors: true,
+            open: true,
+        },
+        esbuild: {
+            treeShaking: true,
+            drop: mode === "production" ? ["console", "debugger"] : [],
+        },
+        build: {
+            minify: "esbuild",
+            chunkSizeWarningLimit: 500, //kbs
+            rollupOptions: {
+                output: {
+                    chunkFileNames: "assets/js/[name]-[hash].js",
+                    entryFileNames: "assets/js/[name]-[hash].js",
+                    assetFileNames: "assets/[ext]/[name]-[hash].[ext]",
+                    // manualChunks(id) {
+                    //   if (id.includes("/node_modules/")) {
+                    //     const name = id.split("/node_modules/")[1].split("/")[0];
+                    //     for (const key of Object.keys(ChunksMap)) {
+                    //       if (ChunksMap[key].includes(name)) {
+                    //         return key;
+                    //       }
+                    //     }
+                    //     return "vendor";
+                    //   }
+                    // },
+
+                    // eslint-disable-next-line no-unused-vars
+                    // manualChunks(id, { getModuleInfo, getModuleIds }) {
+                    //   const getShouldBeVendor = splitVendorChunk();
+                    //   const chunkName = getShouldBeVendor(id, { getModuleInfo });
+                    //   if (chunkName === "vendor") {
+                    //     //1 在node_modules文件夹下
+                    //     //2 不是css类请求
+                    //     //3 是被静态引入的
+                    //     return chunkName;
+                    //   } else if (id.includes("src")) {
+                    //     const moduleInfo = getModuleInfo(id);
+                    //     // console.log(id, "importers", moduleInfo.importers);
+                    //     // console.log(id, "dynamicImporters", moduleInfo.dynamicImporters);
+                    //     if (moduleInfo.importers.length + moduleInfo.dynamicImporters.length > 1) {
+                    //       return "manifest";
+                    //     }
+                    //   }
+                    // },
+
+                    // eslint-disable-next-line no-unused-vars
+                    manualChunks(id) {
+                        if (id.includes("/node_modules/")) {
+                            return id.split("/node_modules/")[1].split("/")[0];
+                        }
+                    },
+                },
+            },
+        },
+    };
+});
\ No newline at end of file

--
Gitblit v1.9.3