-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle.kts
70 lines (62 loc) · 2.01 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import com.rnett.action.addWebpackGenTask
import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler
import org.jetbrains.kotlin.gradle.targets.js.dsl.ExperimentalDistributionDsl
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
plugins {
kotlin("multiplatform")
id("com.github.rnett.ktjs-github-action") version "1.6.0"
}
repositories {
mavenCentral()
}
kotlin {
js(IR) {
val outputDir = layout.projectDirectory.dir("dist")
val outFileName = "index.js"
val webpackTask = addWebpackGenTask()
binaries.executable()
browser {
@OptIn(ExperimentalDistributionDsl::class)
distribution {
outputDirectory = outputDir
distributionName = outFileName
}
webpackTask {
if (mode == KotlinWebpackConfig.Mode.PRODUCTION) {
output.globalObject = "this"
sourceMaps = false
mainOutputFileName = outFileName
dependsOn(webpackTask)
}
}
}
tasks.clean.configure {
delete(outputDir)
}
rootProject.plugins.withType<NodeJsRootPlugin> {
rootProject.the<NodeJsRootExtension>().version = "20.9.0"
}
}
sourceSets {
val jsMain by getting {
dependencies {
listOf("kotlin-js-action", "serialization").forEach {
implementation(group = "com.github.rnett.ktjs-github-action", name = it, version = "1.6.0")
}
implementation(group = "app.softwork", name = "kotlinx-uuid-core-js", version = "0.1.2")
implementation(group = "io.ktor", name = "ktor-client-js", version = "2.3.12")
}
}
}
}
fun KotlinDependencyHandler.implementation(
group: String,
name: String,
version: String? = null,
configure: ExternalModuleDependency.() -> Unit = {}
): ExternalModuleDependency {
val depNot = listOfNotNull(group, name, version).joinToString(":")
return implementation(depNot, configure)
}