Skip to content

Instantly share code, notes, and snippets.

@kevinold
Forked from bokuo-okubo/rn-cli.config.js
Created September 17, 2017 02:32
Show Gist options
  • Save kevinold/0a0b744ebeae8bd815058b5ad331ee1a to your computer and use it in GitHub Desktop.
Save kevinold/0a0b744ebeae8bd815058b5ad331ee1a to your computer and use it in GitHub Desktop.
'use strict';
var blacklist = require('./node_modules/react-native/packager/blacklist');
var path = require('path');
/**
* Default configuration for the CLI.
*
* If you need to override any of this functions do so by defining the file
* `rn-cli.config.js` on the root of your project with the functions you need
* to tweak.
*/
var config = {
getProjectRoots() {
return getRoots();
},
/**
* Specify where to look for assets that are referenced using
* `image!<image_name>`. Asset directories for images referenced using
* `./<image.extension>` don't require any entry in here.
*/
getAssetRoots() {
return getRoots();
},
/**
* Returns a regular expression for modules that should be ignored by the
* packager on a given platform.
*/
getBlacklistRE(platform) {
let root = this.getProjectRoots();
let ignore_path = root + "/web/javascripts/index.js";
return blacklist(platform, [ignore_path]);
}
};
function getRoots() {
if (__dirname.match(/node_modules[\/\\]react-native[\/\\]local-cli$/)) {
// packager is running from node_modules of another project
return [path.resolve(__dirname, '../../..')];
} else if (__dirname.match(/Pods[\/\\]React[\/\\]packager$/)) {
// packager is running from node_modules of another project
return [path.resolve(__dirname, '../../..')];
} else {
return [path.resolve(__dirname, '..')];
}
}
module.exports = config;
@WickyLeung
Copy link

WickyLeung commented Nov 20, 2017

Actually what is the rn-cli.config.js and what's it for?
I just started to code with typescript, and it's a file of one of those steps to set.

@br4nnigan
Copy link

@WickyLeung: nobody knows.

@mjm918
Copy link

mjm918 commented Jun 4, 2019

@br4nnigan: you can create a file named "rn-cli.config.js" and run the following script react-native start --config rn-cli.config.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment