forked from subroh0508/kotlin-material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
58 lines (48 loc) · 1.55 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
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile
import org.jetbrains.kotlin.gradle.plugin.KotlinJsPluginWrapper
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
group = groupId
version = "1.0-SNAPSHOT"
plugins {
kotlin("js") apply false
}
internal val Task.jsOutputDir: File
get() = project.rootProject.buildDir
.resolve("js/packages/${project.name}/kotlin")
internal val Task.jsOutputFileName: String
get() = "${project.name}.js"
val Task.jsOutputFile: String
get() = jsOutputDir.resolve(jsOutputFileName).absolutePath
subprojects {
repositories {
google()
mavenCentral()
maven(url = "https://maven.pkg.jetbrains.space/public/p/kotlinx-html/maven")
maven(url = "https://maven.pkg.jetbrains.space/kotlin/p/kotlin/kotlin-js-wrappers")
}
if (project.name != "sample") {
jsPlugin()
}
}
fun Project.jsPlugin() {
plugins.withType<KotlinJsPluginWrapper> {
extensions.configure<KotlinJsProjectExtension> {
js {
browser()
}
tasks.withType<KotlinJsCompile>().configureEach {
kotlinOptions {
moduleKind = "commonjs"
if (name == "compileKotlinJs") {
outputFile = jsOutputFile
sourceMapEmbedSources = "always"
sourceMap = true
} else {
sourceMap = false
}
}
}
}
}
}