From 2b3715f1610b4176d7abe33e34542389cef61853 Mon Sep 17 00:00:00 2001 From: zhuguifei <zhuguifei@zhuguifeideiMac.local> Date: 星期六, 12 四月 2025 17:12:22 +0800 Subject: [PATCH] Merge branch 'main' of http://lanpucloud.cn:1111/r/eims-master --- eims-ui-mobile/vite-plugins/copyNativeRes.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 files changed, 39 insertions(+), 0 deletions(-) diff --git a/eims-ui-mobile/vite-plugins/copyNativeRes.ts b/eims-ui-mobile/vite-plugins/copyNativeRes.ts new file mode 100644 index 0000000..f92aebc --- /dev/null +++ b/eims-ui-mobile/vite-plugins/copyNativeRes.ts @@ -0,0 +1,39 @@ +import fs from 'fs-extra' +import path from 'path' + +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) + } + }, + } +} -- Gitblit v1.9.3