Hello! How to configure production distibution for...
# javascript
p
Hello! How to configure production distibution for JS target to aplly DCE, but keep all names from obfuscation?
a
So, there are two steps, that works on different levels: 1. Inside your build.gradle.kts you need to add the next snippet:
Copy code
tasks.withType<org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrLink> {
   kotlinOptions.freeCompilerArgs += "-Xir-minimized-member-names=false"
}
p
Thanks!
a
2. If you also need to keep the same name after the webpack, you need to create a directory inside the root of your module with name
webpack.config.d
, and add the next file with any name and
.js
extension:
Copy code
config.module.optimizations?.minimizer = 
   [new TerserPlugin({ terserOptions: { mangle: false } })].concat(config.module.optimizations?.minimizer ?? [])
🙏 1
e
@PHondogo there is also a section of the documentation for this case https://kotlinlang.org/docs/js-ir-compiler.html#minification-of-member-names-in-production
🙏 1