mirror of
https://github.com/status-im/react-native.git
synced 2025-01-09 09:12:02 +00:00
dd9b3e13a9
Summary: This will allow consumers to supply their own transformer to all `react-native` cli commands by simply implementing `rn-cli.config.js` and overriding `getTransformModulePath()`. That way they don't have to fork various parts of the iOS and Android build system that React Native already provides just to add a `--transformer` command line argument. **Test plan:** Applied this patch to the React Native version in my app, implemented `getTransformModulePath()` in my `rn-cli.config.js`, and verified that my custom transformer is invoked. Closes https://github.com/facebook/react-native/pull/7961 Differential Revision: D3404201 Pulled By: foghina fbshipit-source-id: c7eaa85de84d485d06d23a2ffea899821b2cf71c
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
var blacklist = require('../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) {
|
|
return blacklist(platform);
|
|
},
|
|
|
|
/**
|
|
* Returns the path to a custom transformer. This can also be overridden
|
|
* with the --transformer commandline argument.
|
|
*/
|
|
getTransformModulePath() {
|
|
return require.resolve('../packager/transformer');
|
|
},
|
|
};
|
|
|
|
function getRoots() {
|
|
var root = process.env.REACT_NATIVE_APP_ROOT;
|
|
if (root) {
|
|
return [path.resolve(root)];
|
|
}
|
|
if (__dirname.match(/node_modules[\/\\]react-native[\/\\]local-cli$/)) {
|
|
// Packager is running from node_modules.
|
|
// This is the default case for all projects created using 'react-native init'.
|
|
return [path.resolve(__dirname, '../../..')];
|
|
} else if (__dirname.match(/Pods[\/\\]React[\/\\]packager$/)) {
|
|
// React Native was installed using CocoaPods.
|
|
return [path.resolve(__dirname, '../../..')];
|
|
} else {
|
|
return [path.resolve(__dirname, '..')];
|
|
}
|
|
}
|
|
|
|
module.exports = config;
|