mattermost-mobile/metro.config.js
Elias Nahum 61ac4d0f58
MM-18490 Migrate app builds to circleCi (#3373)
* Add pods to source control

* Update Fastlane to work with circleCi

* Configure circleCi workflows to build the app

* Set BRANCH_TO_BUILD env var to CIRCLE_BRANCH for PRs

* Use different context for each platform and type

* Fix regex

* Add i18n check
2019-10-22 17:01:31 +03:00

46 lines
1.5 KiB
JavaScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/* eslint-disable no-console */
const modulePaths = require('./packager/modulePaths');
const resolve = require('path').resolve;
const fs = require('fs');
const platformRegex = /\.(android\.js|ios\.js)/g;
const modulesRegex = /\/(node_modules)/;
// This script will let the react native packager what modules to include
// in the main bundle and what modules to blacklist from the inline requires
// this modules are taken from the modulePaths.js file
const config = {
transformer: {
getTransformOptions: (entryFile, {platform}) => {
console.log('BUILDING MODULES FOR', platform);
const moduleMap = {};
modulePaths.forEach((path) => {
let realPath = path;
if (platform && platformRegex.test(realPath)) {
realPath = path.replace(platformRegex, `.${platform}.js`);
}
let fsFile = realPath;
if (path.match(modulesRegex).length > 1) {
fsFile = path.replace(modulesRegex, '');
}
if (fs.existsSync(fsFile)) {
moduleMap[resolve(realPath)] = true;
}
});
return {
preloadedModules: moduleMap,
transform: {},
};
},
},
maxWorkers: 4,
};
module.exports = config;