Created
March 15, 2022 12:43
-
-
Save giautm/655596dc2bb63818598f61319173879a to your computer and use it in GitHub Desktop.
This file contains 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
import { ConfigPlugin, withGradleProperties } from "@expo/config-plugins"; | |
type PackagingOptionsProp = { | |
pickFirsts?: string[]; | |
excludes?: string[]; | |
merges?: string[]; | |
doNotStrip?: string[]; | |
}; | |
export const withPackagingOptions: ConfigPlugin<PackagingOptionsProp> = ( | |
config, | |
props | |
) => { | |
const toKey = (key: string) => `android.packagingOptions.${key}`; | |
const keys = Object.keys(props).map(toKey); | |
return withGradleProperties(config, (config) => { | |
config.modResults = config.modResults.filter((item) => { | |
if (item.type == "property" && keys.includes(item.key)) { | |
return false; | |
} | |
return true; | |
}); | |
Object.entries(props).forEach(([key, value]) => { | |
if (value) { | |
config.modResults.push({ | |
type: "property", | |
key: toKey(key), | |
value: value.join(","), | |
}); | |
} | |
}); | |
return config; | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment