-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from Lastly1999/main
fix: app-plus、dev/prod、nativeResources插件未被正确移
- Loading branch information
Showing
2 changed files
with
55 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters