Browse Source

config文件处理

lhh 6 months ago
parent
commit
4670deb8f3
3 changed files with 6 additions and 30 deletions
  1. 3 7
      index.html
  2. 0 0
      public/config.js
  3. 3 23
      vite.config.js

+ 3 - 7
index.html

@@ -8,18 +8,14 @@
   </head>
   <body>
     <div id="app"></div>
+    <script type="module" src="/src/main.js"></script>
     <script>
       document.write(
-        "<script type='text/javascript' src='/public/api.config.js?t=" + Date.now() + "'><\/script>"
+        "<script type='text/javascript' src='/config.js?t=" + Date.now() + "'><\/script>"
       );
-    </script>
-    <script>
       document.write(
-        "<script type='text/javascript' src='/public/controlLoad.js?t=" +
-          Date.now() +
-          "'><\/script>"
+        "<script type='text/javascript' src='/controlLoad.js?t=" + Date.now() + "'><\/script>"
       );
     </script>
-    <script type="module" src="/src/main.js"></script>
   </body>
 </html>

public/api.config.js → public/config.js


+ 3 - 23
vite.config.js

@@ -2,30 +2,17 @@ import { fileURLToPath, URL } from 'node:url';
 import { defineConfig } from 'vite';
 import vue from '@vitejs/plugin-vue';
 import postcssPxToViewport from 'postcss-px-to-viewport';
-import commonjs from 'vite-plugin-commonjs';
-// https://vitejs.dev/config/
 export default defineConfig({
   publicDir: 'public',
-  plugins: [
-    vue(),
-    commonjs({
-      include: /utils\/map\/CityGis.Bridge.js/, // 包含的文件路径
-      exclude: [], // 排除的文件路径
-      extensions: ['.js'], // 需要转换的文件扩展名
-      ignoreGlobal: false, // 是否忽略全局变量(例如 Buffer)
-      sourceMap: false, // 是否生成源映射
-      namedExports: {}, // 命名导出(名称和值)
-      ignore: [], // 忽略文件的正则表达式
-      transformMixedEsModules: true // 是否转换混合的 ES 模块
-    })
-  ],
+  base: './',
+  plugins: [vue()],
   server: {
     port: '8090',
     host: '0.0.0.0',
     proxy: {
       '/api': {
         //apiTest是自行设置的请求前缀,按照这个来匹配请求,有这个字段的请求,就会进到代理来
-        target: 'http://10.1.161.180:7878/', // 需要代理的域名
+        target: 'http://10.1.161.187:7878/', // 需要代理的域名
         secure: false,
         changeOrigin: true,
         rewrite: (path) => path.replace(/^\/api/, '') //重写匹配的字段,如果不需要放在请求路径上,可以重写为""
@@ -37,13 +24,6 @@ export default defineConfig({
         changeOrigin: true,
         rewrite: (path) => path.replace(/^\/cityGIsApi/, '') //重写匹配的字段,如果不需要放在请求路径上,可以重写为""
       }
-      // '^/citygis-gateway': {
-      //   //apiTest是自行设置的请求前缀,按照这个来匹配请求,有这个字段的请求,就会进到代理来
-      //   target: 'http://10.1.161.53:30080/', // 需要代理的域名
-      //   secure: false,
-      //   changeOrigin: true,
-      //   rewrite: (path) => path.replace(/^\/citygis-gateway/, 'citygis-gateway/')
-      // }
     }
   },
   resolve: {