I am trying to get a JS app running using Kotlin Multiplatform and webpack. I have a project with the following structure and I am not using intelliJ. This is for an SDK, not a React-web App. Just trying to test the JSApp locally to confirm results.
Authentication/core, creation/core, dataSource, playerSdk, Session all have their own build.gradle.kts configurations.
androidApp, iosApp, and jsApp are all their own implementations of using the core kotlin modules listed.
The root gradle file looks like:
Then as an example, the authentication/core gradle file looks like
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin(“multiplatform”)
id(“com.android.library”)
}
kotlin {
android()
ios {
binaries {
framework {
baseName = “AuthManagerCore”
}
}
}
tvos {
binaries {
framework {
baseName = “AuthManagerCore”
}
}
}
js {
moduleName = “AuthManagerCore”
browser {}
binaries.executable()
useCommonJs()
}
val coroutinesVersion = "1.4.1-native-mt"
sourceSets {
val commonMain by getting {
dependencies {
implementation ("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion"){
version {
strictly(coroutinesVersion)
}
}
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test-annotations-common"))
}
}
val androidMain by getting {
dependencies {
implementation("com.google.android.material:material:1.2.1")
}
}
val androidTest by getting {
dependencies {
implementation(kotlin("test-junit"))
implementation("junit:junit:4.13")
}
}
val iosMain by getting
val iosTest by getting
}
}
android {
compileSdkVersion(29)
sourceSets[“main”].manifest.srcFile(“src/androidMain/AndroidManifest.xml”)
defaultConfig {
minSdkVersion(21)
targetSdkVersion(29)
}
}
val packForXcode by tasks.creating(Sync::class) {
group = “build”
val mode = System.getenv(“CONFIGURATION”) ?: “DEBUG”
val sdkName = System.getenv(“SDK_NAME”) ?: “iphonesimulator”
val targetName = “ios” + if (sdkName.startsWith(“iphoneos”)) “Arm64” else “X64”
val framework = kotlin.targets.getByName(targetName).binaries.getFramework(mode)
inputs.property(“mode”, mode)
dependsOn(framework.linkTask)
val targetDir = File(buildDir, “xcode-frameworks”)
from({ framework.outputDirectory })
into(targetDir)
}
tasks.getByName(“build”).dependsOn(packForXcode)
When I run gradle it builds but does not create the js packages in build/js. Does anyone have suggestions?
Do I need a webpack config in the root? like having Package.swift.
My JsApp is very simple:
Just trying to get an html5 app running.
Any help would be appreciated. Thanks!