facebook / metro

šŸš‡ The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.25k stars 626 forks source link

[Question]: Custom logo and welcome message on Metro server launch? #1154

Closed madclouds closed 11 months ago

madclouds commented 11 months ago

Do you want to request a feature or report a bug? Request a feature

What is the current behavior? Locally a metro server starts in the terminal and a logo is displayed with some other text: CleanShot 2023-12-12 at 15 25 16

What is the expected behavior? I'd like to change this logo and text to provide specific information pertinent to my app. I started looking at the TerminalReporter.js, as that's where the logo is coming from, but I couldn't figure out how to override it?

In the metro.config.js:

const TerminalReporter = require('metro/src/lib/TerminalReporter.js')
const { Terminal } = require('metro-core')
const defaults = getDefaultConfig(__dirname)
class CustomReporter extends TerminalReporter {
  _logInitializing(port, hasReducedPerformance) {
    this.terminal.log('OUR APP INTRO TEXT')
  }
}

Any advice on how to display some intro text from my project when metro starts?

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system. This is for a React Native project

madclouds commented 11 months ago

It would be šŸ„‡ if it was possible to add more custom actions/commands, like:

r - reload the app
d - open developer menu
p - open the profile screen
4 - display logging options
huntie commented 11 months ago

@madclouds I think we're unlikely to offer this level of configuration in Metro.

In terms of your second question, you'd be able to achieve this by creating a forked version of the react-native start command as a React Native CLI plugin, which could live in your app's repo ā€” but I don't recommend this! Adding this configurability in our base CLI plugin is also out of scope.

madclouds commented 11 months ago

I appreciate the response @huntie! We can close this issue.

Could you recommend a technique to print custom output after the metro server starts? I could use console.log() from my app code šŸ¤”, but I want something that gets printed when the metro server spins up.

madclouds commented 11 months ago

I ended up using console.log just fine for our needs šŸ‘