mplive-manifest-plugin.js 703 B

1234567891011121314151617181920212223242526272829303132
  1. const fs = require('fs');
  2. const manifestPath = process.env.UNI_INPUT_DIR + '/manifest.json';
  3. let Manifest = fs.readFileSync(manifestPath, {
  4. encoding: 'utf-8'
  5. });
  6. function mpliveMainfestPlugin(isOpen) {
  7. if (process.env.UNI_PLATFORM !== 'mp-weixin') return;
  8. const manifestData = JSON.parse(Manifest)
  9. if (isOpen === '0') {
  10. delete manifestData['mp-weixin'].plugins['live-player-plugin'];
  11. }
  12. if (isOpen === '1') {
  13. manifestData['mp-weixin'].plugins['live-player-plugin'] = {
  14. "version": "1.3.5",
  15. "provider": "wx2b03c6e691cd7370"
  16. }
  17. }
  18. Manifest = JSON.stringify(manifestData, null, 2)
  19. fs.writeFileSync(manifestPath, Manifest, {
  20. "flag": "w"
  21. })
  22. }
  23. export default mpliveMainfestPlugin