I'm searching for a way to determine in code whether it is being run with jsBrowserDevelopmentRun or...
s
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.
👍 1
a
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
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
Thank you so much! That's exactly what I was looking for.
t
Even special plugin exists, which do configuration in Gradle