const fs = require('fs'); const path = require('path'); const distDir = path.join(__dirname, 'dist', 'build', 'h5'); // 检查index.html const indexHtml = path.join(distDir, 'index.html'); if (fs.existsSync(indexHtml)) { const content = fs.readFileSync(indexHtml, 'utf8'); const jsMatch = content.match(/src="\.\/assets\/(index-[^"]+)\.js"/); if (jsMatch) { console.log('index.html引用的JS:', jsMatch[1]); // 检查这个JS文件是否存在 const jsPath = path.join(distDir, 'assets', `${jsMatch[1]}.js`); if (fs.existsSync(jsPath)) { const jsContent = fs.readFileSync(jsPath, 'utf8'); console.log('主JS文件大小:', jsContent.length); console.log('包含add-btn:', jsContent.includes('add-btn')); console.log('包含累加:', jsContent.includes('累加')); } else { console.log('主JS文件不存在:', jsPath); } } } else { console.log('index.html不存在'); } // 检查weigh页面文件 fs.readdirSync(path.join(distDir, 'assets')).forEach(file => { if (file.includes('weigh')) { const filePath = path.join(distDir, 'assets', file); const content = fs.readFileSync(filePath, 'utf8'); const hasAddBtn = content.includes('add-btn'); const hasLeijia = content.includes('累加'); if (hasAddBtn || hasLeijia) { console.log(`\n${file}:`); console.log(' add-btn:', hasAddBtn); console.log(' 累加:', hasLeijia); console.log(' 大小:', content.length); } } });