Skip to content

Instantly share code, notes, and snippets.

@ndbroadbent
Created May 26, 2017 18:46
Show Gist options
  • Save ndbroadbent/6261dbc0ed60e20a7f71e8987cf18aa7 to your computer and use it in GitHub Desktop.
Save ndbroadbent/6261dbc0ed60e20a7f71e8987cf18aa7 to your computer and use it in GitHub Desktop.
React Native CLI config
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