Sorry for another stupid question: I have a simple...
# javascript
y
Sorry for another stupid question: I have a simple kotlin/js project.
Copy code
kotlin {
    js(IR) {
        browser {
            binaries.executable()
            webpackTask {
                cssSupport.enabled = true
            }
            runTask {
                cssSupport.enabled = true
            }
        }
    }
}
When I run the
build
target it builds and put the result under
<buildDir>/distributions
. I obviously can use
File(buildDir, "distributions")
to access this folder, but I am sure there is some magic variable to get to it. And I suppose my second question/frustration is how on earth can you discover this kind of things without having to ask around in the slack channel? Although I am a big fan of gradle in general, I find it so not discoverable...
r
You can browse sources of the gradle plugin ... 😉
t
1.
distributions
Copy code
val distributions = tasks.getByName<KotlinWebpack>("browserDistribution").destinationDirectory!!
2. In common case such things must be described in docs or FAQs But you can ask questions here 🙂
y
that doesn't work
Copy code
* What went wrong:
Element 'browserDistribution' of type 'org.gradle.api.DefaultTask_Decorated' from container 'task set' cannot be cast to 'org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack'.
t
Update
Copy code
val distributions = tasks.getByName<KotlinWebpack>("browserProductionWebpack").destinationDirectory!!
y
The updated version works (and the !! is not required). Thanks!
t
Also you can find all task in IDEA
Kotlin/JS webpack tasks grouped
build
and
kotlin browser
- most used groups
y
I see. But it's impossible to know that I need to query the one called browserProductionWebpack, cast it to KotlinWebpack and get the destinationDirectory from there
t
Or FAQ or Slack or GitHub 🙂
y
yup. thanks for the help!