diff options
author | jbion <joffrey.bion@amadeus.com> | 2019-07-08 20:39:02 +0200 |
---|---|---|
committer | Joffrey Bion <joffrey.bion@gmail.com> | 2019-08-01 23:01:48 +0200 |
commit | 95f5ffe13a874a397a22e822a00218d3f82e84eb (patch) | |
tree | f0c37b229e1dd93d82f2155f3d747b37dfa25a8c /sw-ui-kt/build.gradle.kts | |
parent | Attempt at Kotlin frontend plugin (diff) | |
download | seven-wonders-95f5ffe13a874a397a22e822a00218d3f82e84eb.tar.gz seven-wonders-95f5ffe13a874a397a22e822a00218d3f82e84eb.tar.bz2 seven-wonders-95f5ffe13a874a397a22e822a00218d3f82e84eb.zip |
Attempt at Kotlin/JS EAP build 1.3.50-eap-54
Diffstat (limited to 'sw-ui-kt/build.gradle.kts')
-rw-r--r-- | sw-ui-kt/build.gradle.kts | 69 |
1 files changed, 29 insertions, 40 deletions
diff --git a/sw-ui-kt/build.gradle.kts b/sw-ui-kt/build.gradle.kts index 5c84a917..a3b453ee 100644 --- a/sw-ui-kt/build.gradle.kts +++ b/sw-ui-kt/build.gradle.kts @@ -1,29 +1,40 @@ -import org.jetbrains.kotlin.gradle.frontend.util.frontendExtension -import org.jetbrains.kotlin.gradle.frontend.webpack.WebPackExtension -import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile +import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack plugins { - id("kotlin2js") - id("org.jetbrains.kotlin.frontend") //version "0.0.45" + kotlin("js") } repositories { - jcenter() + // repository added for kotlin-wrappers resolutions maven(url = "https://kotlin.bintray.com/kotlin-js-wrappers") } -dependencies { - implementation(kotlin("stdlib-js")) - implementation(project(":sw-common-model")) - - implementation("org.jetbrains:kotlin-react-dom:16.6.0-pre.67-kotlin-1.3.11") +kotlin { + target { + browser() + } + sourceSets { + main { + dependencies { + implementation(kotlin("stdlib-js")) + implementation(project(":sw-client")) + + implementation("org.jetbrains:kotlin-react:16.6.0-pre.78-kotlin-1.3.41") + implementation(npm("react", "16.8.3")) + implementation("org.jetbrains:kotlin-react-dom:16.6.0-pre.78-kotlin-1.3.41") + implementation(npm("react-dom", "16.8.3")) + // implementation(npm("@blueprintjs/core", "3.15.1")) + // implementation(npm("react-redux", "5.0.7")) + } + } + } } val staticFilesBuildDir = "${project.buildDir.path}/static" val staticFilesSrcDir = "$projectDir/src/main/web" tasks { - "compileKotlin2Js"(Kotlin2JsCompile::class) { + "compileKotlinJs"(KotlinJsCompile::class) { kotlinOptions.metaInfo = true kotlinOptions.outputFile = "${project.buildDir.path}/js/${project.name}.js" kotlinOptions.sourceMap = true @@ -32,15 +43,16 @@ tasks { } register<Copy>("copyStatic") { - dependsOn("bundle") + dependsOn("assemble") from("${project.buildDir.path}/bundle", staticFilesSrcDir) into(staticFilesBuildDir) - val webpack = project.frontendExtension.bundles().first { it is WebPackExtension } as WebPackExtension - val bundleName = webpack.bundleName - val publicPath = webpack.publicPath + val webpack = project.tasks.withType(KotlinWebpack::class).first() + val bundleFile = webpack.outputPath.name + val publicPath = "/" // TODO get public path from webpack config + filesMatching("*.html") { - expand("bundle" to "$bundleName.bundle.js", "publicPath" to publicPath) + expand("bundle" to bundleFile, "publicPath" to publicPath) } } @@ -48,26 +60,3 @@ tasks { dependsOn("copyStatic") } } - -kotlinFrontend { - - sourceMaps = true - - webpack { - bundleName = "seven-wonders-ui" - contentPath = file(staticFilesBuildDir) - } - - npm { -// dependency("@blueprintjs/core", "3.15.1") - dependency("react", "16.8.3") - dependency("react-dom", "16.8.3") - dependency("react-redux", "5.0.7") - } -} - -fun org.jetbrains.kotlin.gradle.frontend.KotlinFrontendExtension.webpack( - configure: org.jetbrains.kotlin.gradle.frontend.webpack.WebPackExtension.() -> Unit -) { - bundle("webpack", delegateClosureOf(configure)) -} |