How to use the @expo/webpack-config/utils.getRulesByMatchingFiles function in @expo/webpack-config

To help you get started, we’ve selected a few @expo/webpack-config examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github expo / expo-cli / packages / electron-adapter / src / Webpack.ts View on Github external
.map((external: any) => {
        if (typeof external !== 'function') {
          const relPath = path.join('node_modules', external);
          if (!includeFunc(relPath)) return external;
          return null;
        }
        return (ctx: any, req: any, cb: any) => {
          const relPath = path.join('node_modules', req);
          return includeFunc(relPath) ? cb() : external(ctx, req, cb);
        };
      })
      .filter(Boolean);
  }

  // Replace JS babel loaders with Expo loaders that can handle RN libraries
  const rules = getRulesByMatchingFiles(config, [env.locations.appMain]);

  for (const filename of Object.keys(rules)) {
    for (const loaderItem of rules[filename]) {
      (config.module || { rules: [] }).rules.splice(loaderItem.index, 0, babelConfig);
      return config;
    }
  }

  return config;
}