Created
February 25, 2024 09:55
-
-
Save ozcanzaferayan/2ac9cae80f07bda2e3e21be1fef42d4d to your computer and use it in GitHub Desktop.
Expo create custom plugin
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 type { ConfigContext, ExpoConfig } from "@expo/config"; | |
const defineConfig = (_: ConfigContext): ExpoConfig => ({ | |
name: "My project", | |
slug: "my-project", | |
plugins: [ | |
["./plugins/mylibrary.plugin.js"], | |
], | |
}); | |
export default defineConfig; |
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
const { | |
withAppBuildGradle, | |
withProjectBuildGradle, | |
} = require("expo/config-plugins"); | |
module.exports = (config) => { | |
config = withProjectBuildGradle(config, (config) => { | |
const projectGradle = config.modResults; | |
// Add kotlin plugins | |
projectGradle.contents = projectGradle.contents.replace( | |
"dependencies {", | |
'dependencies {\n\t\tclasspath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"' | |
); | |
return config; | |
}); | |
config = withAppBuildGradle(config, (config) => { | |
const appGradle = config.modResults; | |
// Add kotlin plugins | |
appGradle.contents = appGradle.contents.replace( | |
'apply plugin: "com.android.application"', | |
'apply plugin: "com.android.application"\napply plugin: "kotlin-android"\napply plugin: "kotlin-kapt"' | |
); | |
// Add databinding | |
appGradle.contents = appGradle.contents.replace( | |
"android {", | |
"android {\n\tbuildFeatures {\n\t\tdataBinding true\n\t}" | |
); | |
return config; | |
}); | |
return config; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment