metro.config.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* eslint-env node */
  2. /* eslint-disable */
  3. const {
  4. getDefaultConfig
  5. } = require("expo/metro-config");
  6. const path = require("path");
  7. const root = path.resolve(__dirname, "../..");
  8. const nodeModulesPaths = [
  9. path.resolve(__dirname, "node_modules")
  10. ];
  11. const config = getDefaultConfig(__dirname);
  12. config.watchFolders = [root];
  13. config.resolver.extraNodeModules = {
  14. "ncore-ui-kit-mobile": path.resolve(root, "src"),
  15. "react": path.resolve(__dirname, "node_modules/react"),
  16. "react-native": path.resolve(__dirname, "node_modules/react-native")
  17. };
  18. config.resolver.nodeModulesPaths = nodeModulesPaths;
  19. config.resolver.disableHierarchicalLookup = true;
  20. config.resolver.blockList = [
  21. new RegExp(`${path.resolve(root, "example", "web", "node_modules").replace(/\\/g, "\\\\")}.*`),
  22. ];
  23. config.resolver.resolveRequest = (context, moduleName, platform) => {
  24. const forceLocal = ["react", "react-native"];
  25. const match = forceLocal.find(
  26. (pkg) => moduleName === pkg || moduleName.startsWith(`${pkg}/`)
  27. );
  28. if (match) {
  29. const filePath = require.resolve(moduleName, {
  30. paths: [__dirname],
  31. });
  32. return { filePath, type: "sourceFile" };
  33. }
  34. return context.resolveRequest(context, moduleName, platform);
  35. };
  36. module.exports = config;