How to use the metro.loadConfig function in metro

To help you get started, we’ve selected a few metro 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-visualizer / src / middleware / routes.js View on Github external
router.use('/bundle.js', async (req, res, next) => {
  const status = 'Bundling visualizer app';

  const options = {
    dev: true,
    entry: './src/app/index.js',
    minify: false,
    platform: 'web',
  };

  const config = await metro.loadConfig({
    config: require.resolve('./build-utils/metro.config.js'),
  });

  await metro
    .runBuild(config, options)
    .then((val: {code: string, map: string}) => {
      terminal.status(`${status}... serving`);

      res.writeHead(200, {'Content-Type': 'text/javascript'});
      res.write(val.code);
      res.end();

      terminal.status(`${status}, done.`);
      terminal.persistStatus();
    })
    .catch(error => {