How to use the @expo/config/paths.getPossibleProjectRoot function in @expo/config

To help you get started, we’ve selected a few @expo/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 / webpack-config / src / addons / withEntry.ts View on Github external
export default function withEntry(
  webpackConfig: AnyConfiguration,
  env: InputEnvironment = {},
  options: { entryPath: string; strict?: boolean }
): AnyConfiguration {
  env.projectRoot = env.projectRoot || getPossibleProjectRoot();

  const extraAppEntry = projectHasModule(
    options.entryPath,
    env.projectRoot,
    // @ts-ignore
    env.config || getConfig(env)
  );

  if (!extraAppEntry) {
    if (options.strict) {
      throw new Error(
        `[WEBPACK]: The required app entry module: "${options.entryPath}" couldn't be found.`
      );
    }
    // Couldn't resolve the app entry so return the config without modifying it.
    return webpackConfig;
github expo / expo-cli / packages / webpack-config / src / loaders / createBabelLoader.ts View on Github external
}: {
  useCustom?: boolean;
  mode?: Mode;
  babelProjectRoot?: string;
  include?: string[];
  verbose?: boolean;
  [key: string]: any;
} = {}): Rule {
  const ensuredProjectRoot = ensureRoot(babelProjectRoot);
  const modules = [...includeModulesThatContainPaths, ...include];
  const customUse = options.use || {};
  const customUseOptions = customUse.options || {};

  const isProduction = mode === 'production';

  const projectRoot = getPossibleProjectRoot();
  let presetOptions: any = {
    // Explicitly use babel.config.js instead of .babelrc
    babelrc: false,
    // Attempt to use local babel.config.js file for compiling project.
    configFile: true,
  };
  if (
    !fs.existsSync(path.join(projectRoot, 'babel.config.js')) &&
    !fs.existsSync(path.join(projectRoot, '.babelrc'))
  ) {
    presetOptions = {
      babelrc: false,
      configFile: false,
      presets: [require.resolve('babel-preset-expo')],
    };
  }
github expo / expo-cli / packages / webpack-config / src / loaders / createBabelLoader.ts View on Github external
function ensureRoot(possibleProjectRoot?: string): string {
  if (typeof possibleProjectRoot === 'string') {
    return path.resolve(possibleProjectRoot);
  }
  return getPossibleProjectRoot();
}