@@ -7,7 +7,7 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
77import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
88import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
99import 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
1111
1212fun KotlinMultiplatformExtension.jvmTarget (project : Project ) =
1313 with (project) {
@@ -72,6 +72,34 @@ fun KotlinMultiplatformExtension.jvmTarget(project: Project) =
7272 }
7373 }
7474
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+
75103fun KotlinMultiplatformExtension.webDeps (project : Project ) =
76104 with (project) {
77105 sourceSets {
@@ -80,87 +108,22 @@ fun KotlinMultiplatformExtension.webDeps(project: Project) =
80108 api(libs.ktor.client.js)
81109 api(libs.kotlinx.browser)
82110 // api(npm("@js-joda/timezone", libs.versions.npm.jsjoda.tz.get()))
83- // ksp(project(":meta:ksp:processor"))
84111 }
85-
86112 // kotlin.srcDir("src/main/kotlin")
87113 // resources.srcDir("src/main/resources")
88114 }
89-
90- webTest { kotlin {} }
91115 }
92116 }
93117
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+ }
111122
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+ }
164127
165128fun KotlinMultiplatformExtension.wasmWasiTarget (project : Project ) =
166129 with (project) {
0 commit comments