I am new Kotlin and Kotlin/JS. I am trying to setu...
# javascript
p
I am new Kotlin and Kotlin/JS. I am trying to setup a webapp project that takes the javascript output file of a Kotlin multiplaform project, webpack bundle it with kotlin.js, ktor-ktor-client-js.js, kotlinx-serialization-kotlinx-serialization-runtime.js etc and run it, run DCE/tree-shaking on it, and output the final bundle. I am finding it very difficult to setup the build.gradle file to do these. Kotlin’s example project for DCE tool is couple years old, so thats not much help. Can someone point me to some example project whose build.gradle I could copy from to achieve what I described above.
k
i
Since 1.3.70 your use case is covered by gradle plugin by default Now 1.3.70 in eap stage
r
The example given is for the kotlin-js gradle plugin. @prab was asking about a multiplatform plugin example. I would be interested in a multiplatform example that outputs a single file (including dependencies) as well. Is that even possible?
i
@rnentjes yes, it is possible TL; DR You need to replace “target” on “js” in dsl, and you need to write js specific code in “jsMain” source folder, and common code in “commonMain” Check please https://kotlinlang.org/docs/reference/building-mpp-with-gradle.html You can write subtarget inside js block
Copy code
js {
   browser()
}