@nx/react-native
Version:
34 lines (33 loc) • 1.6 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = update;
const devkit_1 = require("@nx/devkit");
const web_configuration_1 = require("../../generators/web-configuration/web-configuration");
/**
* Add web configuration to react native projects
* - delete the current serve target which is just a pass-through to start target
* - rename the babel.config.json to to babel-v72.config.json
* - add web confiugration, it will add .babelrc.js
*/
async function update(tree) {
const projects = (0, devkit_1.getProjects)(tree);
const tasks = [];
for (const [projectName, config] of projects.entries()) {
if (config.targets?.['start']?.executor === '@nx/react-native:start') {
if (config.targets['serve'] &&
config.targets['serve'].executor === 'nx:run-commands' &&
config.targets['serve'].options?.command?.startsWith('nx start')) {
delete config.targets['serve'];
(0, devkit_1.updateProjectConfiguration)(tree, projectName, config);
}
if (tree.exists((0, devkit_1.joinPathFragments)(config.root, 'babel.config.json'))) {
tree.rename((0, devkit_1.joinPathFragments)(config.root, 'babel.config.json'), (0, devkit_1.joinPathFragments)(config.root, 'babel-v72.config.json'));
}
tasks.push(await (0, web_configuration_1.default)(tree, {
project: config.name,
bundler: 'webpack',
}));
}
}
return (0, devkit_1.runTasksInSerial)(...tasks);
}
;