Created
May 26, 2017 18:46
-
-
Save ndbroadbent/6261dbc0ed60e20a7f71e8987cf18aa7 to your computer and use it in GitHub Desktop.
React Native CLI config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path') | |
const sharedBlacklist = [] | |
const platformBlacklists = { | |
ios: [ | |
'.web.js', | |
'.macos.js', | |
/node_modules\/react-native-web\/.*/, | |
/node_modules\/react-native-windows\/.*/, | |
/node_modules\/react-native-macos\/.*/, | |
/node_modules\/[^/]+\/\.git\/.*/, | |
], | |
android: [ | |
'.web.js', | |
'.windows.js', | |
'.macos.js', | |
/node_modules\/react-native-web\/.*/, | |
/node_modules\/react-native-windows\/.*/, | |
/node_modules\/react-native-macos\/.*/, | |
/node_modules\/[^/]+\/\.git\/.*/, | |
], | |
web: [ | |
'.windows.js', | |
'.macos.js', | |
/node_modules\/react-native-windows\/.*/, | |
/node_modules\/react-native-macos\/.*/, | |
/node_modules\/[^/]+\/\.git\/.*/, | |
], | |
windows: [ | |
'.web.js', | |
'.macos.js', | |
/node_modules\/react-native-web\/.*/, | |
/node_modules\/react-native-macos\/.*/, | |
/node_modules\/[^/]+\/\.git\/.*/, | |
], | |
macos: [ | |
'.web.js', | |
'.windows.js', | |
/node_modules\/react-native-web\/.*/, | |
/node_modules\/react-native-windows\/.*/, | |
/node_modules\/[^/]+\/\.git\/.*/, | |
], | |
} | |
function escapeRegExp(pattern) { | |
if (Object.prototype.toString.call(pattern) === '[object RegExp]') { | |
return pattern.source.replace(/\//g, path.sep); | |
} else if (typeof pattern === 'string') { | |
const escaped = pattern.replace(/[\-\[\]\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&') | |
// convert the '/' into an escaped local file separator | |
return escaped.replace(/\//g, `\\${path.sep}`) | |
} | |
throw new Error(`Unexpected packager blacklist pattern: ${pattern}`) | |
} | |
function blacklist(platform, additionalBlacklist) { | |
// eslint-disable-next-line | |
return new RegExp('(' + | |
(additionalBlacklist || []).concat(sharedBlacklist) | |
.concat(platformBlacklists[platform] || []) | |
.map(escapeRegExp) | |
.join('|') + | |
')$') | |
} | |
module.exports = { | |
getBlacklistRE(platform) { | |
if (process && process.argv.filter(a => a.indexOf('react-native-macos') > -1).length > 0) { | |
return blacklist('macos') | |
} | |
return blacklist('ios') | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment