Is there a way to obfuscate the production app exp...
# compose-web
a
Is there a way to obfuscate the production app exported using
webBrowserDistribution
? I noticed that when I run it I can find the kotlin code on the Sources tab. This is for a JS target (not wasm)
r
webBrowserDistribution
doesn't seem to be any of the standard Kotlin plugin tasks
Do you mean
jsBrowserDistribution
?
a
yes my bad. i have renamed the target. it is the same as
jsBrowserDistribution
r
For me this task doesn't generate any source maps.
just a minified js bundle
a
same here. but when i serve it from my server and visit the page, i can see the full kotlin code. ex see https://composablehorizons.github.io/compose-menu/
r
You have an iframe there - are you sure you are not putting some kind of localhost dev server in this iframe?
a
it is indeed an iframe which is pointing to the
index.html
file generated in the bundle
it's the same result like running
./gradlew jsBrowserProductionRun
and checking the sources tab
i
Try jsBrowserProductionWebpack
Actually that's not working either, I can still see the kotlin code
r
Where does it come from?
It shouldn't be generated with distribution task
a
the demo is generated using this script. https://github.com/composablehorizons/compose-menu/blob/main/scripts/update_demo.sh which is using
jsBrowserDistribution
i tried locally and removing the .map file removes the kt code from the sources tab. nice
It shouldn't be generated with distribution task
@Robert Jaros are you sure about this? (as in is it documented somewhere?) i guess it somewhat makes sense to have the mappings generated, if the code is minified/obfuscated.
if it isnt meant to do this, which task is meant for production distribution?
r
I was kind of sure, because it doesn't generate source maps in my project. But I've built your code and it indeed does generate.
a
the project is using compose
1.6.2
and tried also on
1.6.10
. which version are u on?
r
I'm on 1.6.10-rc3, but I don't think the compose version has anything to do with this
Ok, I've found the difference
1
I have custom webpack configuration in my project
in a
webpack.config.d
folder I have
webpack.js
file with:
Copy code
if (config.devServer) {
  // other things
} else {
    config.devtool = undefined;
}
This devtool option disables source maps generation for production build
I'm using it for a long time in all my projects, so I've fogotten about this ;)
You can put
webpack.config.d
inside
demo
subproject
You can also use:
Copy code
js(IR) {
    browser {
        webpackTask {
            sourceMaps = false
        }
    }
}
💯 5
a
nice. it worked!