Hi everyone. I’m trying to understand what the act...
# javascript
c
Hi everyone. I’m trying to understand what the actual differences in behaviour are between the gradle tasks:
build
,
browserDevelopmentWebpack
and
browserProductionWebpack
, and also how they differ from setting the webpack mode to
PRODUCTION
or
DEVELOPMENT
in
build.gradle.kts
. I ask this because I was using
browserDevelopmentWebpack
but with
mode=PRODUCTION
, which seem like they would conflict with each other, and the resulting bundle appeared to be a development bundle (not minified, not DCE’d).
a
I wasn't aware you can set webpack mode in
build.gradle.kts
. However, even if you can. My advice will just be don't. Why? you already have gradle tasks at hand. You need a production build, you just run
browserProductionWebpack
, you need a development build, you run the alternative. Differences you ask. In the JS world, normally javascript is shipped uglified & minified to reduce bundle size. While this is desirable for production builds, it is not during development. You still need to be able to inspect your code and see what the variable name is not really worrying about size. So, to summurize,
browserProductionWebpack
will first assemble all your dependencies, eliminate dead code, and then proceed to minify your compiled javascript. while
browserDevelopmentWebpack
will just assemble all your dependencies and serve them unminified. Resulting to faster responses compared to
browserProductionWebpack
👍 1
❤️ 1
c
Thanks @andylamax that’s great to know I shouldn’t be using webpack’s
mode
. And how does
build
differ from
browserProductionWebpack
? I had been using
build
to generate my deployable code but I’m thinking
browserProductionWebpack
is all I need.
a
build
does more than just invoking
browserProductionWebpack
, it also runs checks and tests. And yes, provided that you are in confidence to deploy,
browserProductionWebpack
is the task you are looking for
c
Perfect, thanks for the great answers. Much appreciated!
b
I'd even recommend using browserProductionDistribution for deployment
1
That way all the files you need appear in build/dist
👍 1
c
Hey how do you set up weback or gradle to dev mode 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