@@ -7,7 +7,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
7
7
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
8
8
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
9
9
import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsBinaryMode
10
- import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig
10
+ import org.jetbrains.kotlin.gradle.targets.js.dsl.KotlinJsTargetDsl
11
11
12
12
fun KotlinMultiplatformExtension.jvmTarget (project : Project ) =
13
13
with (project) {
@@ -72,6 +72,34 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
72
72
}
73
73
}
74
74
75
+ fun KotlinJsTargetDsl.webConfig (project : Project ) =
76
+ with (project) {
77
+ browser {
78
+ commonWebpackConfig {
79
+ cssSupport { enabled = true }
80
+ // outputFileName = "app.js"
81
+ // scssSupport { enabled = true }
82
+ // sourceMaps = true
83
+ }
84
+
85
+ runTask { sourceMaps = false }
86
+ testTask {
87
+ enabled = true
88
+ testLogging { configureLogEvents() }
89
+ useKarma { useChromeHeadless() }
90
+ }
91
+
92
+ // distribution { outputDirectory = file("$projectDir/docs") }
93
+ }
94
+
95
+ if (isSharedProject.not ()) {
96
+ binaries.executable()
97
+ }
98
+ generateTypeScriptDefinitions()
99
+ compilerOptions { configureKotlinJs() }
100
+ testRuns.configureEach { executionTask.configure {} }
101
+ }
102
+
75
103
fun KotlinMultiplatformExtension.webDeps (project : Project ) =
76
104
with (project) {
77
105
sourceSets {
@@ -80,87 +108,22 @@ fun KotlinMultiplatformExtension.webDeps(project: Project) =
80
108
api(libs.ktor.client.js)
81
109
api(libs.kotlinx.browser)
82
110
// api(npm("@js-joda/timezone", libs.versions.npm.jsjoda.tz.get()))
83
- // ksp(project(":meta:ksp:processor"))
84
111
}
85
-
86
112
// kotlin.srcDir("src/main/kotlin")
87
113
// resources.srcDir("src/main/resources")
88
114
}
89
-
90
- webTest { kotlin {} }
91
115
}
92
116
}
93
117
94
- fun KotlinMultiplatformExtension.jsTarget (project : Project ) =
95
- with (project) {
96
- js {
97
- browser {
98
- commonWebpackConfig {
99
- cssSupport { enabled = true }
100
- // outputFileName = "js-app.js"
101
- // scssSupport { enabled = true }
102
- // sourceMaps = true
103
- }
104
-
105
- runTask { sourceMaps = false }
106
- testTask {
107
- enabled = true
108
- testLogging { configureLogEvents() }
109
- useKarma { useChromeHeadless() }
110
- }
118
+ fun KotlinMultiplatformExtension.jsTarget (project : Project ) {
119
+ js { webConfig(project) }
120
+ webDeps(project)
121
+ }
111
122
112
- // distribution { outputDirectory = file("$projectDir/docs") }
113
- }
114
-
115
- if (isSharedProject.not ()) {
116
- binaries.executable()
117
- }
118
- generateTypeScriptDefinitions()
119
- compilerOptions { configureKotlinJs() }
120
- testRuns.configureEach { executionTask.configure {} }
121
- }
122
- webDeps(project)
123
- }
124
-
125
- fun KotlinMultiplatformExtension.wasmJsTarget (project : Project ) =
126
- with (project) {
127
- wasmJs {
128
- // moduleName = "wasm-app"
129
- browser {
130
- val rootDirPath = project.rootDir.path
131
- val projectDirPath = project.projectDir.path
132
- commonWebpackConfig {
133
- cssSupport { enabled = true }
134
- // outputFileName = "wasm-app.js"
135
- // sourceMaps = true
136
- devServer =
137
- (devServer ? : KotlinWebpackConfig .DevServer ()).apply {
138
- static =
139
- (static ? : mutableListOf ()).apply {
140
- // Serve sources to debug inside the browser
141
- add(projectDirPath)
142
- add(rootDirPath)
143
- }
144
- }
145
- }
146
-
147
- runTask { sourceMaps = false }
148
- testTask {
149
- enabled = true
150
- testLogging { configureLogEvents() }
151
- useKarma { useChromeHeadless() }
152
- }
153
- }
154
-
155
- if (isSharedProject.not ()) {
156
- binaries.executable()
157
- }
158
- generateTypeScriptDefinitions()
159
- compilerOptions { configureKotlinJs() }
160
- testRuns.configureEach { executionTask.configure {} }
161
- }
162
- webDeps(project)
163
- }
123
+ fun KotlinMultiplatformExtension.wasmJsTarget (project : Project ) {
124
+ wasmJs { webConfig(project) }
125
+ webDeps(project)
126
+ }
164
127
165
128
fun KotlinMultiplatformExtension.wasmWasiTarget (project : Project ) =
166
129
with (project) {
0 commit comments