Align Taro pages with Next hub/nav/book/community/VIP, pack the single-index Xiaohongshu portal with host-chrome safe areas, and refresh shared book content plus portal README constraints. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.1 KiB
JavaScript
42 lines
1.1 KiB
JavaScript
/**
|
|
* Taro copy.patterns 偶发不落盘;构建后强制把 icons / assets 拷进 dist。
|
|
*/
|
|
import fs from 'fs'
|
|
import path from 'path'
|
|
import { fileURLToPath } from 'url'
|
|
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
const target = process.env.TARO_APP_TARGET || 'weapp'
|
|
const out =
|
|
target === 'tt' ? 'dist/tt' : target === 'xhs' ? 'dist/xhs' : 'dist/weapp'
|
|
|
|
function copyDir(from, to) {
|
|
if (!fs.existsSync(from)) {
|
|
console.warn(`[copy-weapp-static] skip missing: ${from}`)
|
|
return 0
|
|
}
|
|
fs.mkdirSync(to, { recursive: true })
|
|
let n = 0
|
|
for (const name of fs.readdirSync(from)) {
|
|
const src = path.join(from, name)
|
|
const dest = path.join(to, name)
|
|
const st = fs.statSync(src)
|
|
if (st.isDirectory()) n += copyDir(src, dest)
|
|
else {
|
|
fs.copyFileSync(src, dest)
|
|
n += 1
|
|
}
|
|
}
|
|
return n
|
|
}
|
|
|
|
const icons = copyDir(
|
|
path.join(root, 'src/public/icons'),
|
|
path.join(root, out, 'icons'),
|
|
)
|
|
const assets = copyDir(
|
|
path.join(root, 'src/assets'),
|
|
path.join(root, out, 'assets'),
|
|
)
|
|
console.log(`[copy-weapp-static] ${out}: icons=${icons} assets=${assets}`)
|