Mark Vogel
11/29/2022, 5:47 PMnpm run-script build
(i.e. react-scripts build
).
Does anyone know a way for Gradle to compile the React JavaScript code in my JS module and then use that compiled code as the dependency to include and interop?turansky
11/29/2022, 7:52 PMMark Vogel
11/29/2022, 9:27 PMMark Vogel
11/29/2022, 9:30 PMturansky
11/29/2022, 9:43 PMSergei Grishchenko
11/30/2022, 10:40 AMval kotlinJsTarget = project.kotlinExtension.targets.firstNotNullOf { it as? KotlinJsTarget }
val kotlinJsCompilation =
kotlinJsTarget.compilations.first { it.name == KotlinCompilation.MAIN_COMPILATION_NAME }
NodeJsExec.create(kotlinJsCompilation, "convert") {
group = KARAKUM_GRADLE_PLUGIN_GROUP
dependsOn("unpackEmbeddedJsLibrary")
inputFileProperty.set(embeddedJsLibrary.file("karakum-converter.js"))
doLast {
println("Hello from plugin 'team.karakum.converter'")
}
}
It will work approximately this way
node karakum-converter.js
All deps will be handle according to npm env of gradle project, you also can dig into NodeJsExec
task to explore more about custom node tasksMark Vogel
11/30/2022, 2:48 PM