Browse Source

feat: 打包结构更改

bill 4 weeks ago
parent
commit
5e8b1d1a63

+ 1 - 2
index.html

@@ -2,9 +2,8 @@
 <html lang="en">
 <html lang="en">
   <head>
   <head>
     <meta charset="UTF-8" />
     <meta charset="UTF-8" />
-    <link rel="icon" type="image/svg+xml" href="/favicon.ico" />
+    <link rel="icon" id="ico" type="image/svg+xml" href="/favicon.ico" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title><%- title %></title>
   </head>
   </head>
   <body>
   <body>
     <div id="app"></div>
     <div id="app"></div>

+ 5 - 3
package.json

@@ -4,11 +4,13 @@
   "version": "1.0.0",
   "version": "1.0.0",
   "type": "module",
   "type": "module",
   "scripts": {
   "scripts": {
-    "dev:fuse": "vite --mode=fusedev",
-    "build:fusetest": "vite build --mode=fusetest",
-    "build:fuse": "vite build --mode=fuse",
+    "dev:fuse": "vite --mode=criminaldev",
+    "build:fusetest": "vite build --mode=firetest && vite build --mode=criminaltest",
+    "build:fuse": "vite build --mode=fire && vite build --mode=criminal",
+
     "dev:hx": "vite --mode=hxdev",
     "dev:hx": "vite --mode=hxdev",
     "build:hx": "vite build --mode=hx",
     "build:hx": "vite build --mode=hx",
+
     "dev:jm": "vite --mode=jmdev",
     "dev:jm": "vite --mode=jmdev",
     "build:jm": "vite build --mode=jm"
     "build:jm": "vite build --mode=jm"
   },
   },

+ 15 - 0
profile/.env.criminal

@@ -0,0 +1,15 @@
+VITE_PRIMARY='#0960bd'
+VITE_TITLE='绘图'
+VITE_ENTRY='/example/fuse/enter-mix.ts'
+VITE_ENTRY_EXAMPLE='./main.ts'
+VITE_MESH_OSS='https://4dkk.4dage.com/'
+VITE_MESH_API='https://www.4dkankan.com/'
+VITE_CLOUD_API='https://laser.4dkankan.com/backend/'
+VITE_FUSE_API='https://mix3d.4dkankan.com/'
+VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&host=https://4dkk.4dage.com/v4/www&server=https://www.4dkankan.com&oss=https://4dkk.4dage.com/'
+VITE_CLOUD_VIEW='https://laser.4dkankan.com/index.html?m={m}&lang=zh'
+VITE_FUSE_VIEW='https://mix3d.4dkankan.com/'
+VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+
+VITE_BUILD_DIR="criminal"
+VITE_ICO="./icos/criminal.ico"

+ 17 - 0
profile/.env.criminaldev

@@ -0,0 +1,17 @@
+VITE_PRIMARY='#0960bd'
+VITE_TITLE='绘图'
+VITE_ENTRY='/example/fuse/enter-mix.ts'
+VITE_ENTRY_EXAMPLE='./main.ts'
+VITE_MOCK_ENV=criminaltest
+
+VITE_MESH_OSS='/meshOSS/'
+VITE_MESH_API='/meshAPI/'
+VITE_CLOUD_API='/cloudAPI/'
+VITE_FUSE_API='/fuseAPI/'
+
+VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&host=https://4dkk.4dage.com/v4-test/www&server=https://test.4dkankan.com&oss=https://4dkk.4dage.com/'
+VITE_CLOUD_VIEW='https://uat-laser.4dkankan.com/uat/index.html?m={m}&lang=zh'
+VITE_FUSE_VIEW='https://test-mix3d.4dkankan.com/'
+VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+
+VITE_ICO="./icos/criminal.ico"

+ 18 - 0
profile/.env.criminaltest

@@ -0,0 +1,18 @@
+VITE_PRIMARY='#0960bd'
+VITE_TITLE='绘图'
+VITE_ENTRY='/example/fuse/enter-mix.ts'
+VITE_ENTRY_EXAMPLE='./main.ts'
+
+VITE_OSS_ROOT="https://4dkk.4dage.com/"
+VITE_MESH_OSS='https://4dkk.4dage.com/'
+VITE_MESH_API='https://test.4dkankan.com/'
+VITE_CLOUD_API='https://uat-laser.4dkankan.com/uat/'
+VITE_FUSE_API='https://test-mix3d.4dkankan.com/'
+
+VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&host=https://4dkk.4dage.com/v4-test/www&server=https://test.4dkankan.com&oss=https://4dkk.4dage.com/'
+VITE_CLOUD_VIEW='https://uat-laser.4dkankan.com/uat/index.html?m={m}&lang=zh'
+VITE_FUSE_VIEW='https://test-mix3d.4dkankan.com/'
+VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+
+VITE_BUILD_DIR="criminal"
+VITE_ICO="./icos/criminal.ico"

+ 3 - 0
.env.fuse

@@ -10,3 +10,6 @@ VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&host=https://4dkk.4dage.com/v
 VITE_CLOUD_VIEW='https://laser.4dkankan.com/index.html?m={m}&lang=zh'
 VITE_CLOUD_VIEW='https://laser.4dkankan.com/index.html?m={m}&lang=zh'
 VITE_FUSE_VIEW='https://mix3d.4dkankan.com/'
 VITE_FUSE_VIEW='https://mix3d.4dkankan.com/'
 VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
 VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+
+VITE_BUILD_DIR="fire"
+VITE_ICO="./icos/fire.ico"

+ 4 - 2
.env.fusedev

@@ -2,7 +2,7 @@ VITE_PRIMARY='#D8000A'
 VITE_TITLE='绘图'
 VITE_TITLE='绘图'
 VITE_ENTRY='/example/fuse/enter-mix.ts'
 VITE_ENTRY='/example/fuse/enter-mix.ts'
 VITE_ENTRY_EXAMPLE='./main.ts'
 VITE_ENTRY_EXAMPLE='./main.ts'
-VITE_MOCK_ENV=fusetest
+VITE_MOCK_ENV=firetest
 
 
 VITE_MESH_OSS='/meshOSS/'
 VITE_MESH_OSS='/meshOSS/'
 VITE_MESH_API='/meshAPI/'
 VITE_MESH_API='/meshAPI/'
@@ -12,4 +12,6 @@ VITE_FUSE_API='/fuseAPI/'
 VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&host=https://4dkk.4dage.com/v4-test/www&server=https://test.4dkankan.com&oss=https://4dkk.4dage.com/'
 VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&host=https://4dkk.4dage.com/v4-test/www&server=https://test.4dkankan.com&oss=https://4dkk.4dage.com/'
 VITE_CLOUD_VIEW='https://uat-laser.4dkankan.com/uat/index.html?m={m}&lang=zh'
 VITE_CLOUD_VIEW='https://uat-laser.4dkankan.com/uat/index.html?m={m}&lang=zh'
 VITE_FUSE_VIEW='https://test-mix3d.4dkankan.com/'
 VITE_FUSE_VIEW='https://test-mix3d.4dkankan.com/'
-VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+
+VITE_ICO="./icos/fire.ico"

+ 4 - 1
.env.fusetest

@@ -12,4 +12,7 @@ VITE_FUSE_API='https://test-mix3d.4dkankan.com/'
 VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&host=https://4dkk.4dage.com/v4-test/www&server=https://test.4dkankan.com&oss=https://4dkk.4dage.com/'
 VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh&host=https://4dkk.4dage.com/v4-test/www&server=https://test.4dkankan.com&oss=https://4dkk.4dage.com/'
 VITE_CLOUD_VIEW='https://uat-laser.4dkankan.com/uat/index.html?m={m}&lang=zh'
 VITE_CLOUD_VIEW='https://uat-laser.4dkankan.com/uat/index.html?m={m}&lang=zh'
 VITE_FUSE_VIEW='https://test-mix3d.4dkankan.com/'
 VITE_FUSE_VIEW='https://test-mix3d.4dkankan.com/'
-VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+VITE_LOGIN_VIEW='https://test-mix3d.4dkankan.com/fire/?redirect={redirect}#login'
+
+VITE_BUILD_DIR="fire"
+VITE_ICO="./icos/fire.ico"

+ 1 - 1
.env.hx

@@ -11,4 +11,4 @@ VITE_FUSE_API='/'
 VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh'
 VITE_MESH_VIEW='./static/kankan.html?m={m}&lang=zh'
 VITE_CLOUD_VIEW='/swss/index.html?m={m}&lang=zh'
 VITE_CLOUD_VIEW='/swss/index.html?m={m}&lang=zh'
 VITE_FUSE_VIEW='/code/'
 VITE_FUSE_VIEW='/code/'
-VITE_LOGIN_VIEW='/admin/index.html#/login?redirect={redirect}'
+VITE_LOGIN_VIEW='/admin/index.html#/login?redirect={redirect}'

.env.hxdev → profile/.env.hxdev


.env.hxtest → profile/.env.hxtest


.env.jm → profile/.env.jm


.env.jmdev → profile/.env.jmdev


.env.jmg → profile/.env.jmg


.env.jmtest → profile/.env.jmtest


BIN
public/icos/criminal.ico


BIN
public/icos/fire.ico


+ 6 - 1
src/example/fuse/main.ts

@@ -13,4 +13,9 @@ app.component('Icon', Icon)
 app.use(router)
 app.use(router)
 app.mount('#app')
 app.mount('#app')
 
 
-console.log('当前版本', window.__VERSION__)
+console.log('当前版本', window.__VERSION__)
+
+console.log(import.meta.env)
+if (import.meta.env.VITE_ICO) {
+  document.querySelector('#ico')?.setAttribute('href', import.meta.env.VITE_ICO)
+}

+ 10 - 6
vite.config.ts

@@ -6,13 +6,16 @@ import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
 import { version } from "./package.json";
 import { version } from "./package.json";
 import fs from 'fs'
 import fs from 'fs'
 
 
+const envDir = process.cwd() + '/profile'
+
 // https://vite.dev/config/
 // https://vite.dev/config/
 export default ({ mode }: any) => {
 export default ({ mode }: any) => {
-  const env = loadEnv(mode, process.cwd());
+  const env = loadEnv(mode, envDir);
 
 
   let proxy: any = {};
   let proxy: any = {};
   if (env.VITE_MOCK_ENV) {
   if (env.VITE_MOCK_ENV) {
-    const mockEnv = loadEnv(env.VITE_MOCK_ENV, process.cwd());
+    const mockEnv = loadEnv(env.VITE_MOCK_ENV, envDir);
+    console.log('mockEnv', mockEnv)
 
 
     const getProxy = (prev: string, api: string) => ({
     const getProxy = (prev: string, api: string) => ({
       target: api,
       target: api,
@@ -20,7 +23,6 @@ export default ({ mode }: any) => {
       rewrite: (path: any) => path.replace(prev, ""),
       rewrite: (path: any) => path.replace(prev, ""),
     });
     });
 
 
-    console.log(env, env.VITE_MOCK_ENV, mockEnv);
     if (env.VITE_MOCK_PROXY) {
     if (env.VITE_MOCK_PROXY) {
       proxy[env.VITE_MOCK_PROXY] = getProxy(
       proxy[env.VITE_MOCK_PROXY] = getProxy(
         env.VITE_MOCK_PROXY,
         env.VITE_MOCK_PROXY,
@@ -33,12 +35,14 @@ export default ({ mode }: any) => {
         }
         }
       }
       }
     }
     }
-  }
-
-  console.log("===>", proxy);
 
 
+    console.log(proxy)
+  }
+  const outDir = env.VITE_BUILD_DIR || ''
   return defineConfig({
   return defineConfig({
+    envDir: envDir,
     build: {
     build: {
+      outDir: `dist/${outDir}`,
       rollupOptions: {
       rollupOptions: {
         // 防止打包时处理指定目录
         // 防止打包时处理指定目录
         external: [
         external: [