Nikky
11/05/2019, 1:06 PMribesg
11/05/2019, 1:06 PMNikky
11/05/2019, 1:07 PMribesg
11/05/2019, 1:07 PMribesg
11/05/2019, 1:07 PMsdeleuze
11/05/2019, 5:52 PMNikky
11/06/2019, 9:54 AMval bundleTask = tasks.create("${target.name}Bundle") {
dependsOn(copyJsTask)
group = "build"
val dir = file("build/bundle")
val outputDir = dir.resolve("out/js/")
outputs.dir(outputDir.parentFile)
doLast {
val inputFolder = dir.resolve("input/")
inputFolder.deleteRecursively()
file("build/kotlin-js-min/${target.name}/main/").copyRecursively(inputFolder)
file("node_modules/almond/almond.js").copyTo(inputFolder.resolve("almond.js"), true)
outputDir.deleteRecursively()
outputDir.mkdirs()
exec {
workingDir(inputFolder)
commandLine(
localBin("r.js"),
"-o", "baseUrl=.", "name=almond.js",
"include=penta,almond",
"insertRequire=penta",
"out=${outputDir.resolve("bundle.js")}",
"wrap=true"
)
logger.lifecycle(commandLine.joinToString(" "))
}
copy {
from(outputDir)
from("src/clientJsMain/web")
into(dir)
}
}
}
there are some more tasks.. copyJsTask
extract the dce output
and then i use bundleTask.output
in a copy task
this bundles and mangles the javascript code from 20 Mb into a single 2.1 Mb file that can be directly used
PS: one could also reference almond.js in the original location, but then the js code will contain the original source location /home/nikky/dev/....
and although it loads anyways.. i prefer to copy it over and have just a relative reference
PPS: if anybody else got something like this working with amd-bundle or similar without the need for almond.js i would really love to seepatrickdelconte
11/07/2019, 10:36 AMNikky
11/07/2019, 11:26 AMNikky
11/07/2019, 11:27 AM