apply plugin: 'kotlin-platform-js' apply plugin: 'org.jetbrains.kotlin.frontend' apply plugin: 'kotlinx-serialization' kotlinFrontend { webpackBundle { bundleName = "main" contentPath = file('src/main/web') mode = production ? "production" : "development" } define "PRODUCTION", production } dependencies { if (!project.gradle.startParameter.taskNames.contains("generatePomFileForMavenProjectPublication")) { compile project(":kvision-modules:kvision-base") } else { compile rootProject } } task cleanLibs(type: Delete) { delete 'build/js', 'build/libs' } if (project.gradle.startParameter.taskNames.contains("jar")) { compileKotlin2Js.dependsOn 'cleanLibs' } jar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } compileKotlin2Js { kotlinOptions.metaInfo = true kotlinOptions.outputFile = "$project.buildDir.path/js/${project.name}.js" kotlinOptions.sourceMap = !production kotlinOptions.moduleKind = 'umd' } compileTestKotlin2Js { kotlinOptions.metaInfo = true kotlinOptions.outputFile = "$project.buildDir.path/js-tests/${project.name}-tests.js" kotlinOptions.sourceMap = !production kotlinOptions.moduleKind = 'umd' } task copyResources(type: Copy) { from "src/main/resources" into file(buildDir.path + "/js") } task copyResourcesForTests(type: Copy) { from "src/main/resources" into file(buildDir.path + "/js-tests/") } afterEvaluate { tasks.getByName("webpack-bundle") { dependsOn(copyResources) } tasks.getByName("webpack-run") { dependsOn(copyResources) } tasks.getByName("karma-start") { dependsOn(copyResources, copyResourcesForTests) } }