当使用 IntelliJ 创建多平台项目时,它似乎不像 js 项目那样创建 kotlin.js (std lib)。
最佳答案
正如文档中所述 where the kotlin.js
is mentioned :
Note: ... In a Maven or Gradle build, no library files are copied by default to the compilation output directory, see the corresponding tutorials for the instructions.
Kotlin Multiplatform 项目构建始终使用 Gradle 运行,您需要引用 Gradle tutorial ,其中表示:
By default, Gradle does not expand the JARs in the build process, so we need to add an additional step in our build to do so:
task assembleWeb(type: Sync) { configurations.compile.each { File file -> from(zipTree(file.absolutePath), { includeEmptyDirs = false include { fileTreeElement -> def path = fileTreeElement.path path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/")) } }) } from compileKotlin2Js.destinationDir into "${projectDir}/web" dependsOn classes } assemble.dependsOn assembleWeb
This task copies both dependencies runtime files and the compilation output to the web directory.
关于kotlin - intelliJ 将 kotlin.js 放在多平台项目中的什么位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46915905/