frank
05/23/2020, 1:27 AMplugins {
id("org.jetbrains.kotlin.js") version "1.4-M1"
}
repositories {
maven("<https://dl.bintray.com/kotlin/kotlin-eap>")
jcenter()
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-js"))
}
kotlin.target {
useCommonJs()
nodejs()
}
tasks.compileKotlinJs {
kotlinOptions.outputFile = "routes/node/index2.js"
kotlinOptions.metaInfo = false
}
My Enviroment:
- Gradle: 6.4.1 (compatible with JDK 14)
- IDEA last eap. (With previus versions the same)
- Kotlin 1.4-M1(I tried with old versions)Ilya Goncharov [JB]
05/23/2020, 7:51 AMVladislav86
05/23/2020, 1:24 PMIlya Goncharov [JB]
05/23/2020, 1:30 PMoutputFile
In fact I don’t recommend to do it because now NPM project is build, and compilation output in part of this NPM project. It is necessary now to setup build infrastructure and so on.
If you want, you can create Copy
task, which can copy compilation output after compile task.frank
05/23/2020, 10:18 PMIlya Goncharov [JB]
05/25/2020, 7:44 AMtasks.register("syncCompileKotlinJs", Copy::class.java) {
val compile = tasks.withType(org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile::class.java).named("compileKotlinJs")
into("routes/node") {
from(
compile
.map {
it.outputFile.parentFile
}
)
}
into("$buildDir")
dependsOn(compile)
}
frank
05/28/2020, 8:42 PMIlya Goncharov [JB]
05/28/2020, 8:46 PM