Reading <https://kotlinlang.org/docs/reference/j...
# javascript
r
Reading https://kotlinlang.org/docs/reference/js-project-setup.html, the part about development/production webpack:
Execute either of these tasks to obtain the respective artifacts for development or production.
But is there a way to set up build types via gradle, such that one can run
browserDevelopmentWebpack
when running locally and
browserProductionWebpack
when running for production somehow? In Android you have build variants https://developer.android.com/studio/build/build-variants. Using raw webpack you can do i.e.
Copy code
webpack --mode=development
But is there a way to do something like this for KotlinJS via gradle?
I can see someone else asked something similar: https://kotlinlang.slack.com/archives/C0B8L3U69/p1586651769296700. Does anyone have good experience with the approach that was suggested? It seems to be more for environment variables.
r
But what would you like to configure?
You can't really configure anything with Kotlin/JS for the browser.
There are no environment variables and no properties you can read from Kotlin/JS code.
Nevertheless, if I needed something similar, I would probably create two different
index.html
files with some global JS variables defined inside them.
r
I guess it is more of a gradle question then - I want to build with
browserDevelopmentWebpack
locally, and
browserProductionWebpack
in production. I feel like that must be a pretty common use case?
c
Hey Similar thing here. How do you set up weback or gradle to use browserDevelopment in a Multiplatform project, jvm server + kotlin/js + react client ? Assigning Mode.Development in CommonWebpackConfig still build the clientBrowserProduction task instead of the clientBrowserDevelopment task