Unverified Commit d6008a3a authored by Shagen Ogandzhanian's avatar Shagen Ogandzhanian Committed by GitHub

Js resources corrected (#189)

* Introduce static index.html, switch to the build itself to 1.5.10 (since this is a version we are building skiko as of now)

* Include both wasm and "normal" resources
parent c48ee3cc
import org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension
plugins { plugins {
kotlin("multiplatform") version "1.5.21" kotlin("multiplatform") version "1.5.10"
} }
repositories { repositories {
...@@ -16,6 +18,22 @@ if (project.hasProperty("skiko.version")) { ...@@ -16,6 +18,22 @@ if (project.hasProperty("skiko.version")) {
val resourcesDir = "$buildDir/resources/" val resourcesDir = "$buildDir/resources/"
val skikoWasm by configurations.creating
dependencies {
skikoWasm("org.jetbrains.skiko:skiko-js-wasm-runtime:$version")
}
val unzipTask = tasks.register("unzipWasm", Copy::class) {
destinationDir = file(resourcesDir)
from(skikoWasm.map { zipTree(it) })
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>().configureEach {
dependsOn(unzipTask)
}
kotlin { kotlin {
js(IR) { js(IR) {
...@@ -33,23 +51,15 @@ kotlin { ...@@ -33,23 +51,15 @@ kotlin {
// We cannot use it directly but need to extract data from there. // We cannot use it directly but need to extract data from there.
implementation("org.jetbrains.skiko:skiko-js-runtime:$version") implementation("org.jetbrains.skiko:skiko-js-runtime:$version")
} }
resources.setSrcDirs(listOf(resourcesDir)) resources.setSrcDirs(resources.srcDirs + unzipTask.get().destinationDir)
} }
} }
} }
val skikoWasm by configurations.creating // a temporary workaround for a bug in jsRun invocation - see https://youtrack.jetbrains.com/issue/KT-48273
afterEvaluate {
dependencies { extensions.configure<NodeJsRootExtension> {
skikoWasm("org.jetbrains.skiko:skiko-js-wasm-runtime:$version") versions.webpackDevServer.version = "4.0.0"
} }
val unzipTask = tasks.register("unzipWasm", Copy::class) {
destinationDir = file(resourcesDir)
from(skikoWasm.map { zipTree(it) })
}
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinJsCompile>().configureEach {
dependsOn(unzipTask)
} }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>skiko for web demo</title>
<script src="skiko.js"> </script>
<script src="SkiaJsSample.js"> </script>
</head>
<body>
<h1>Skiko For Web</h1>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment