How to use the metro-config.loadConfig function in metro-config

To help you get started, we’ve selected a few metro-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 facebook / metro / packages / metro / src / commands / serve.js View on Github external
async function restart(): Promise {
      if (restarting) {
        return;
      } else {
        restarting = true;
      }

      if (server) {
        // eslint-disable-next-line no-console
        console.log('Configuration changed. Restarting the server...');
        await promisify(server.close).call(server);
      }

      const config = await loadConfig(argv);

      server = await MetroApi.runServer(config, argv);

      restarting = false;
    }
github facebook / metro / packages / metro / src / commands / serve.js View on Github external
async function restart(): Promise {
      if (restarting) {
        return;
      } else {
        restarting = true;
      }

      if (server) {
        // eslint-disable-next-line no-console
        console.log('Configuration changed. Restarting the server...');
        await promisify(server.close).call(server);
      }

      const config = await loadConfig(argv);

      server = await MetroApi.runServer(config, argv);

      restarting = false;
    }
github godaddy / ekke / api / metro / configure.js View on Github external
async function configure(flags) {
  const reactNativePath = path.dirname(require.resolve('react-native/package.json'));
  const config = await loadConfig();
  const custom = {
    resolver: {},
    serializer: {},
    transformer: {},
    cacheStores: [
      new FileStore({
        root: flags['cache-location']
      })
    ]
  };

  //
  // We need to create a fake package name that we will point to the root
  // of the users directory so we can resolve their requires and test files
  // without having to rely on `package.json` based resolve due to poor
  // handling of absolute and relative paths.
github facebook / metro / packages / metro / src / commands / build.js View on Github external
handler: makeAsyncCommand(async (argv: any) => {
    const config = await loadConfig(argv);

    await MetroApi.runBuild(config, {
      ...argv,
      onBegin: (): void => {
        updateReporter.update({
          buildID: '$',
          type: 'bundle_build_started',
          bundleDetails: {
            entryFile: argv.entry,
            platform: argv.platform,
            dev: !!argv.dev,
            minify: !!argv.optimize,
            bundleType: 'Bundle',
          },
        });
      },
github facebook / metro / packages / metro / src / commands / dependencies.js View on Github external
handler: makeAsyncCommand(async (argv: any) => {
    const config = await loadConfig(argv);
    await dependencies(argv, config);
  }),
});
github facebook / metro / packages / metro / src / commands / build.js View on Github external
handler: makeAsyncCommand(async (argv: any) => {
    const config = await loadConfig(argv);

    await MetroApi.runBuild(config, {
      ...argv,
      onBegin: (): void => {
        updateReporter.update({
          buildID: '$',
          type: 'bundle_build_started',
          bundleDetails: {
            entryFile: argv.entry,
            platform: argv.platform,
            dev: !!argv.dev,
            minify: !!argv.optimize,
            bundleType: 'Bundle',
          },
        });
      },
github react-native-community / cli / packages / cli / src / util / loadMetroConfig.js View on Github external
export default async function load(
  ctx: ContextT,
  options?: ConfigOptionsT = {}
): Promise {
  const defaultConfig = getDefaultConfig(ctx);

  const config = await loadConfig(
    {
      cwd: ctx.root,
      ...options,
    },
    defaultConfig
  );

  return config;
}
github react-native-community / cli / packages / cli / src / tools / loadMetroConfig.ts View on Github external
export default function load(
  ctx: Config,
  options?: ConfigOptionsT,
): Promise {
  const defaultConfig = getDefaultConfig(ctx);
  if (options && options.reporter) {
    defaultConfig.reporter = options.reporter;
  }
  return loadConfig({cwd: ctx.root, ...options}, defaultConfig);
}
github react-native-community / cli / packages / local-cli / util / Config.js View on Github external
async load(configFile: ?string): Promise {
    const argv = {cwd: getProjectRoot()};

    return await loadConfig(
      configFile ? {...argv, config: configFile} : argv,
      this.DEFAULT,
    );
  },
};
github react-native-community / cli / util / Config.js View on Github external
async load(configFile: ?string): Promise {
    const argv = {cwd: getProjectRoot()};

    return await loadConfig(
      configFile ? {...argv, config: configFile} : argv,
      this.DEFAULT,
    );
  },
};