Browse Source

fix(vite-plugins): 仅在生产环境构建时更新package.json

feige996 10 months ago
parent
commit
c6d4a46968
1 changed files with 3 additions and 0 deletions
  1. 3 0
      vite-plugins/updatePackageJson.ts

+ 3 - 0
vite-plugins/updatePackageJson.ts

@@ -7,6 +7,9 @@ const updatePackageJson = (): Plugin => {
   return {
     name: 'update-package-json',
     async buildStart() {
+      // 只在生产环境构建时执行
+      if (process.env.NODE_ENV !== 'production') return
+
       const packageJsonPath = path.resolve(process.cwd(), 'package.json')
 
       try {