https://kotlinlang.org logo
#javascript
Title
# javascript
s

Sean Proctor

10/18/2023, 4:05 PM
I'm searching for a way to determine in code whether it is being run with jsBrowserDevelopmentRun or jsBrowserProductionWebpack. I saw a suggestion to use multiple html pages and set variables in them, but the method to do that is not obvious.
a

Artem Kobzar

10/18/2023, 4:30 PM
I don't feel that we have such intrinsic in our kotlin.js package, but you can make a ticket for it, and it's possible that we would add it.
r

Robert Jaros

10/18/2023, 4:49 PM
You can use webpack
DefinePlugin
for this. Put this in some *.js file in `webpack.config.d`:
Copy code
;(function() {
    const webpack = require('webpack')
    config.plugins.push(new webpack.DefinePlugin({
        build_mode: JSON.stringify(config.mode),
    }));
})();
And define
external val build_mode: String
in your Kotlin code.
s

Sean Proctor

10/18/2023, 8:41 PM
Thank you so much! That's exactly what I was looking for.
t

turansky

10/19/2023, 6:32 AM
Even special plugin exists, which do configuration in Gradle
3 Views