summaryrefslogtreecommitdiff
path: root/sw-ui/build.gradle.kts
blob: 9965ce85411cfa4c1c97d4476187673ca29b3298 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack

plugins {
    kotlin("js")
}

repositories {
    mavenCentral()
    // for kotlin-wrappers resolutions
    maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
    // for kotlinx-html (dependency of kotlin-react-dom)
    maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
    jcenter() // for kotlinx-html-jvm:0.7.2 needed by dokka (and not migrated)
}

val kotlinWrappersVersion = "pre.150-kotlin-1.4.31"

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

                val reactVersion = "17.0.2"
                implementation("org.jetbrains:kotlin-react:$reactVersion-$kotlinWrappersVersion")
                implementation(npm("react", reactVersion))
                implementation("org.jetbrains:kotlin-react-dom:$reactVersion-$kotlinWrappersVersion")
                implementation(npm("react-dom", reactVersion))

                val reactReduxVersion = "7.2.2"
                implementation("org.jetbrains:kotlin-react-redux:$reactReduxVersion-$kotlinWrappersVersion")
                implementation(npm("react-redux", reactReduxVersion))
                // redux version aligned with the wrapper's build:
                // https://github.com/JetBrains/kotlin-wrappers/blob/master/gradle.properties#L42
                implementation(npm("redux", "4.0.5"))

                val reactRouterDomVersion = "5.2.0"
                implementation("org.jetbrains:kotlin-react-router-dom:$reactRouterDomVersion-$kotlinWrappersVersion")
                implementation(npm("react-router-dom", reactRouterDomVersion))

                val styledComponentsVersion = "5.2.1"
                implementation("org.jetbrains:kotlin-styled:$styledComponentsVersion-$kotlinWrappersVersion")
                implementation(npm("styled-components", styledComponentsVersion))
                implementation(npm("inline-style-prefixer", "6.0.0"))

                val bpCoreVersion = "3.42.0"
                val bpIconsVersion = "3.26.0"
                val bpWrapperVersion = "1"
                implementation("org.hildan.blueprintjs:kotlin-blueprintjs-core:$bpCoreVersion-$bpWrapperVersion")
                implementation("org.hildan.blueprintjs:kotlin-blueprintjs-icons:$bpIconsVersion-$bpWrapperVersion")
                implementation(npm("@blueprintjs/core", bpCoreVersion))
                implementation(npm("@blueprintjs/icons", bpIconsVersion))
            }
        }
        test {
            dependencies {
                implementation(kotlin("test-js"))
            }
        }
    }
}

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

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

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