diff --git a/package.json b/package.json index 803b198..23c3b40 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "packageManager": "pnpm@10.10.0", "description": "unibest - 最好的 uniapp 开发模板", "unibest-version": "3.3.0", - "update-time": "2025-07-08", "generate-time": "用户创建项目时生成", "author": { "name": "feige996", diff --git a/vite-plugins/copyNativeRes.ts b/vite-plugins/copyNativeRes.ts deleted file mode 100644 index 5a461d2..0000000 --- a/vite-plugins/copyNativeRes.ts +++ /dev/null @@ -1,41 +0,0 @@ -import path from 'node:path' -import process from 'node:process' -import fs from 'fs-extra' - -export function copyNativeRes() { - const waitPath = path.resolve(__dirname, '../src/nativeResources') - const buildPath = path.resolve( - __dirname, - '../dist', - process.env.NODE_ENV === 'production' ? 'build' : 'dev', - process.env.UNI_PLATFORM!, - 'nativeResources', - ) - - return { - enforce: 'post', - async writeBundle() { - try { - // 检查源目录是否存在 - const sourceExists = await fs.pathExists(waitPath) - if (!sourceExists) { - console.warn(`[copyNativeRes] 警告:源目录 "${waitPath}" 不存在,跳过复制操作。`) - return - } - - // 确保目标目录及中间目录存在 - await fs.ensureDir(buildPath) - console.log(`[copyNativeRes] 确保目标目录存在:${buildPath}`) - - // 执行文件夹复制 - await fs.copy(waitPath, buildPath) - console.log( - `[copyNativeRes] 成功将 nativeResources 目录中的资源移动到构建目录:${buildPath}`, - ) - } - catch (error) { - console.error(`[copyNativeRes] 复制资源失败:`, error) - } - }, - } -} diff --git a/vite-plugins/updatePackageJson.ts b/vite-plugins/updatePackageJson.ts deleted file mode 100644 index bd93d6a..0000000 --- a/vite-plugins/updatePackageJson.ts +++ /dev/null @@ -1,37 +0,0 @@ -// src/plugins/updatePackageJson.ts -import type { Plugin } from 'vite' -import fs from 'node:fs/promises' -import path from 'node:path' -import process from 'node:process' - -function 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 { - // 读取并解析 package.json - const content = await fs.readFile(packageJsonPath, 'utf-8') - const packageJson = JSON.parse(content) - - // 更新时间戳(使用 ISO 格式或自定义格式) - packageJson['update-time'] = new Date().toISOString().split('T')[0] // YYYY-MM-DD - - // 写回文件(保持 2 空格缩进) - await fs.writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`, 'utf-8') - - console.log(`[update-package-json] 更新时间戳: ${packageJson['update-time']}`) - } - catch (error) { - console.error('[update-package-json] 插件执行失败:', error) - } - }, - } -} - -export default updatePackageJson diff --git a/vite.config.ts b/vite.config.ts index eb0cccd..b939d20 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -21,7 +21,6 @@ import { visualizer } from 'rollup-plugin-visualizer' import AutoImport from 'unplugin-auto-import/vite' import { defineConfig, loadEnv } from 'vite' import ViteRestart from 'vite-plugin-restart' -import updatePackageJson from './vite-plugins/updatePackageJson' // https://vitejs.dev/config/ export default async ({ command, mode }) => { @@ -130,7 +129,6 @@ export default async ({ command, mode }) => { dts: 'src/types/components.d.ts', // 自动生成的组件类型声明文件路径(用于 TypeScript 支持) }), Uni(), - updatePackageJson(), ], define: { __UNI_PLATFORM__: JSON.stringify(UNI_PLATFORM),