hello, I was wondering what the right way to manag...
# javascript
k
hello, I was wondering what the right way to manage the different domain names between local and deployed when working with Kotlin JS? Thanks
With Node you would use
.env
files but that's not gonna work with a static site
c
Two solutions I've used in the past: • if the server is hosting the JS page: use
document.location
to know where you're getting served from • to add more information: have a
/config
endpoint on the server that allows the client to find out Both of these feel more like workarounds than proper solutions though
t
string-replace-loader
?
k
@CLOVIS yeah, we were thinking about hosting on Cloudflare directly since it's a static site for performance reasons, but that would rule out the
document.location
trick as the api is going to be on a server somewhere else
are there any examples of setting a production flag to
webpack.config.js
when building with gradle? If so then we could pass that in when we're building in our CI job
t
It’s possible in KFC You can check generated code, which use
string-replace-loader
👍 1
k
Cool, will go down this path. Thanks!
if you follow the gist attached to the above thread (https://gist.github.com/CameronProbert/85b7d60fa9572d93566f5c5ee62441e0) just note you need to change one thing for Webpack 5:
Copy code
args.plusAssign(listOf("--env", "buildMode=$buildMode"))