5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 07:21:32 +08:00
wails/website/docs/guides/obfuscated.mdx
2024-05-05 17:36:08 +10:00

47 lines
1.4 KiB
Plaintext

# Obfuscated Builds
Wails includes support for obfuscating your application using [garble](https://github.com/burrowers/garble).
To produce an obfuscated build, you can use the `-obfuscate` flag with the `wails build` command:
```bash
wails build -obfuscated
```
To customise the obfuscation settings, you can use the `-garbleargs` flag:
```bash
wails build -obfuscated -garbleargs "-literals -tiny -seed=myrandomseed"
```
These settings may be persisted in your [project config](../reference/project-config.mdx).
## How it works
In a standard build, all bound methods are available in the frontend under the `window.go`
variable. When these methods are called, the corresponding backend method is called using
the fully qualified function name. When using an obfuscated build, methods are bound using
an ID instead of a name. The bindings generated in the `wailsjs` directory use these IDs to
call the backend functions.
:::note
To ensure that your application will work in obfuscated mode, you must use the generated
bindings under the `wailsjs` directory in your application.
:::
## Example
Importing the "Greet" method from the bindings like this:
```js
import { Greet } from "../../wailsjs/go/main/App";
// snip
Greet("World");
```
will ensure that the method will work correctly in obfuscated mode, as the bindings will
be regenerated with IDs and the call mechanism updated.