Nenhuma descrição

react-native.config.js 1.4KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * This cli config is needed for the coexistance of react-native and other
  3. * out-of-tree implementations such react-native-macos.
  4. * The following issue is tracked by
  5. * https://github.com/react-native-community/discussions-and-proposals/issues/182
  6. *
  7. * The work-around involves having a metro.config.js for each out-of-tree
  8. * platform, i.e. metro.config.js for react-native and
  9. * metro.config.macos.js for react-native-macos.
  10. * This react-native.config.js looks for a --use-react-native-macos
  11. * switch and when present pushes --config=metro.config.macos.js
  12. * and specifies reactNativePath: 'node_modules/react-native-macos'.
  13. * The metro.config.js has to blacklist 'node_modules/react-native-macos',
  14. * and conversely metro.config.macos.js has to blacklist 'node_modules/react-native'.
  15. */
  16. 'use strict';
  17. const macSwitch = '--use-react-native-macos';
  18. const windowsSwitch = '--use-react-native-windows';
  19. if (process.argv.includes(macSwitch)) {
  20. process.argv = process.argv.filter(arg => arg !== macSwitch);
  21. process.argv.push('--config=metro.config.macos.js');
  22. module.exports = {
  23. reactNativePath: 'node_modules/react-native-macos',
  24. };
  25. }
  26. else if (process.argv.includes(windowsSwitch)) {
  27. process.argv = process.argv.filter(arg => arg !== windowsSwitch);
  28. process.argv.push('--config=metro.config.windows.js');
  29. module.exports = {
  30. reactNativePath: 'node_modules/react-native-windows',
  31. };
  32. }