summaryrefslogtreecommitdiff
path: root/sw-ui-kt/build.gradle.kts
blob: 9dd871596a347efd2bd9aeb6def7e506182c91ec (plain)
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
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack

plugins {
    kotlin("js")
}

repositories {
    // repository added for kotlin-wrappers resolutions
    maven(url = "https://kotlin.bintray.com/kotlin-js-wrappers")
}

kotlin {
    target {
        browser()
    }
    sourceSets {
        main {
            dependencies {
                implementation(kotlin("stdlib-js"))
                implementation(project(":sw-client"))

                implementation("org.jetbrains:kotlin-react:16.8.6-pre.80-kotlin-1.3.41")
                implementation(npm("react", "16.8.6"))

                implementation("org.jetbrains:kotlin-react-dom:16.8.6-pre.80-kotlin-1.3.41")
                implementation(npm("react-dom", "16.8.6"))

                implementation("org.jetbrains:kotlin-react-redux:5.0.7-pre.80-kotlin-1.3.41")
                implementation(npm("react-redux", "5.0.7"))
                implementation(npm("redux", "4.0.4"))

                // seems to be required by "kotlin-extensions" JS lib
                implementation(npm("core-js", "3.1.4"))

                // implementation(npm("@blueprintjs/core", "3.15.1"))
            }
        }
    }
}

tasks {
    compileKotlinJs {
        kotlinOptions.metaInfo = true
        kotlinOptions.sourceMap = true
        // non-plain module kind is necessary to use top-level declarations from UMD modules (e.g. react-redux)
        // because the Kotlin wrapper didn't specify @JsNonModule
        kotlinOptions.moduleKind = "commonjs"
        kotlinOptions.main = "call"
    }

    "processResources"(ProcessResources::class) {
        val webpack = project.tasks.withType(KotlinWebpack::class).first()
        into(webpack.destinationDirectory!!)

        val bundleFile = webpack.archiveFile.name
        val publicPath = "./" // TODO get public path from webpack config

        filesMatching("*.html") {
            expand("bundle" to bundleFile, "publicPath" to publicPath)
        }
    }
}
bgstack15