Преглед на файлове

build: 修复打包后会请求两次app.config.js问题

louhangfei преди 1 година
родител
ревизия
7518f1db7d
променени са 3 файла, в които са добавени 18 реда и са изтрити 20 реда
  1. 1 1
      build/script/postBuild.ts
  2. 16 16
      build/vite/plugin/html.ts
  3. 1 3
      package.json

+ 1 - 1
build/script/postBuild.ts

@@ -20,4 +20,4 @@ export const runBuild = async () => {
     process.exit(1);
   }
 };
-runBuild();
+// runBuild();

+ 16 - 16
build/vite/plugin/html.ts

@@ -4,8 +4,8 @@
  */
 import type { PluginOption } from 'vite';
 import { createHtmlPlugin } from 'vite-plugin-html';
-import pkg from '../../../package.json';
-import { GLOB_CONFIG_FILE_NAME } from '../../constant';
+// import pkg from '../../../package.json';
+// import { GLOB_CONFIG_FILE_NAME } from '../../constant';
 import { simpleGit } from 'simple-git';
 const git = simpleGit();
 
@@ -21,9 +21,9 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean): Promise<Plugin
 
   const path = './';
 
-  const getAppConfigSrc = () => {
-    return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${pkg.version}-${new Date().getTime()}`;
-  };
+  // const getAppConfigSrc = () => {
+  //   return `${path || '/'}${GLOB_CONFIG_FILE_NAME}?v=${pkg.version}-${new Date().getTime()}`;
+  // };
 
   return new Promise((resolve) => {
     getLatestHash().then((hash) => {
@@ -35,17 +35,17 @@ export function configHtmlPlugin(env: ViteEnv, isBuild: boolean): Promise<Plugin
             title: VITE_GLOB_APP_TITLE,
             hash,
           },
-          // Embed the generated app.config.js file
-          tags: isBuild
-            ? [
-                {
-                  tag: 'script',
-                  attrs: {
-                    src: getAppConfigSrc(),
-                  },
-                },
-              ]
-            : [],
+          // // Embed the generated app.config.js file
+          // tags: isBuild
+          //   ? [
+          //       {
+          //         tag: 'script',
+          //         attrs: {
+          //           src: getAppConfigSrc(),
+          //         },
+          //       },
+          //     ]
+          //   : [],
         },
       });
       resolve(htmlPlugin);

+ 1 - 3
package.json

@@ -7,7 +7,6 @@
     "bootstrap": "pnpm install",
     "serve": "pnpm run dev",
     "dev": "vite",
-    "createConfig": "esno ./build/script/postBuild.ts",
     "build": "cross-env NODE_ENV=production vite build",
     "build:test": "cross-env vite build --mode test && esno ./build/script/postBuild.ts",
     "build:no-cache": "pnpm clean:cache && pnpm run build",
@@ -25,8 +24,7 @@
     "test prod gzip": "http-server dist --cors --gzip -c-1",
     "reinstall": "rimraf pnpm-lock.yaml && rimraf package.lock.json && rimraf node_modules && pnpm run bootstrap",
     "build typecheck": "vuedx-typecheck . && vite build",
-    "deploy": "gh-pages -d dist",
-    "publish": "esno ./build/publish/publish.ts"
+    "deploy": "gh-pages -d dist"
   },
   "dependencies": {
     "@element-plus/icons-vue": "2.0.9",