Getting Started
Install Metro using npm
:
npm install --save-dev metro
Or via yarn
:
yarn add --dev metro
Running metro
#
Right now, Metro Bundler cannot run by itself. Instead, some functions are exposed so that the configuration can be passed into it. First, require the module by doing:
const metroBundler = require('metro');
Within the object returned, two main methods are given:
Method createServer(serverOptions)
#
Given a set of options (same ones as the build
method), a metro-server
will be returned. You can then hook this into a proper HTTP(S) server by using its processRequest
method:
'use strict'; +
Getting Started
Install Metro using npm
:
npm install --save-dev metro metro-core
Or via yarn
:
yarn add --dev metro metro-core
Running metro
#
Right now, Metro Bundler cannot run by itself. Instead, some functions are exposed so that the configuration can be passed into it. First, require the module by doing:
const metroBundler = require('metro');
Within the object returned, two main methods are given:
Method createServer(serverOptions)
#
Given a set of options (same ones as the build
method), a metro-server
will be returned. You can then hook this into a proper HTTP(S) server by using its processRequest
method:
'use strict'; const http = require('http'); const metroBundler = require('metro'); const TerminalReporter = require('metro/src/lib/TerminalReporter'); -const Terminal = require('metro/src/lib/Terminal'); +const Terminal = require('metro-core/src/Terminal'); const metroBundlerServer = metroBundler.createServer({ assetRegistryPath: __dirname,