Is there an "official" way to have production/deve...
# webassembly
c
Is there an "official" way to have production/development env/distribution? seems like there is no way to pick development/production compilation/distribution targets? This seems not like the best/but only way... https://gist.github.com/CameronProbert/85b7d60fa9572d93566f5c5ee62441e0
t
Browser? Node.js?
c
Browser
So jsBrowserDistribution
t
Do you want to have 1 bundle, but run it in different and use it different envs?
Or you want to build 2 separate (production/development) bundles?
c
two different bundles, or at least be able to define different environment (host/port) for distribution vs running locally
t
In webpack you can use
DefinePlugin
to solve this problem.
We used it previously for the same problem.
c
Yeah so have to do webpack stuff instead of just being able to have two kotlin srcs
t
Bundler is more powerfull - it will process all sources
I have multiple libraries, where I use same flag
c
How does the bundler know what I'm targeting tho?
As there is only one task in gradle
or is distribution always production?
t
distribution is production by default
c
I see
t
You can change mode in common case
We use Vite and Vite supports it by default
3 separate property-files
Copy code
.env
.env.production
.env.development
Webpack can have similar plugin 🙄
c
I see ok, yeah was just hoping to try and keep it all in kotlin/gradle, but I guess this is the only really decent way right now 😞
t
DotEnv probably will fit better
(less js code)
c
Yeah I think I saw that, you have a default then a
.env.production
from what I understand?
t
Yes, but it's not how it works in
DotEnv
(as I see)
I have Gradle-only solution for you too
c
Oh cool, that would be preferable, we really only need to tweak the hostname and port, nothing crazy
t
You can add filters for Sync tasks
Main idea: 1. You have Sync tasks
IncrementalSyncTask
for both modes 2. You can add custom sync task berore it and replace content with default filter. I created custom, because my case is complex 3. PROFIT
c
dang lol, I think I did something like that a while back for some jvm resources
This might be a nice addtion for your plugin btw, sure theres others struggling with the same thing
t
We use KFC, which already provides Vite support for Kotlin/JS
c
oh cool
t
One more Gradle option - add Vite support for WasmJS in KFC 😉
sure theres others struggling with the same thing
🧌
c
Well coming from Android where you can just dump things into BuildConfig or resources and create different build types, kinda cumbersome jumping between build systems
t
cc @Michael Porotkin
🤝 1
@chrisjenx I added
wasmJs
target support to KFC. Now you can use Vite with
wasmJs
target too. Are you ready to try? 😉
With
.env
OOB support 😜