petstore-frontend/scripts/verify-mp-app-json.cjs
2026-04-12 22:57:48 +08:00

22 lines
789 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 确保微信小程序产物 app.json 含 lazyCodeLoading代码质量「组件按需注入」依赖此项
*/
const fs = require('fs')
const path = require('path')
const root = path.join(__dirname, '..')
const appJsonPath = path.join(root, 'dist/build/mp-weixin/app.json')
if (!fs.existsSync(appJsonPath)) {
console.error('[verify-mp-app-json] 未找到:', appJsonPath)
process.exit(1)
}
const app = JSON.parse(fs.readFileSync(appJsonPath, 'utf8'))
if (app.lazyCodeLoading !== 'requiredComponents') {
console.error('[verify-mp-app-json] app.json 缺少 lazyCodeLoading: "requiredComponents",请检查 src/manifest.json 中 mp-weixin 配置后重新编译。')
process.exit(1)
}
console.log('[verify-mp-app-json] OK已启用组件按需注入 lazyCodeLoading')