const fs = require('fs') const path = require('path') // Taro's React custom tabBar does not emit its local WXSS. WeChat reads this // file from the custom-tab-bar directory, so copy it after every build. const tabBarStyleSource = path.join(process.cwd(), 'src', 'custom-tab-bar', 'index.wxss') const tabBarStyleTarget = path.join(process.cwd(), 'dist', 'custom-tab-bar', 'index.wxss') fs.copyFileSync(tabBarStyleSource, tabBarStyleTarget) const templatePath = path.join(process.cwd(), 'dist', 'base.wxml') const source = fs.readFileSync(templatePath, 'utf8') const original = '' const replacement = '' if (source.includes(replacement)) { process.exit(0) } if (!source.includes(original)) { throw new Error('Skyline share-element template was not found') } fs.writeFileSync(templatePath, source.replace(original, replacement), 'utf8')