Requirements
The agent-poisoner packages declare Node 24 or later, and the plugin needs Vite 6 or later (peer dependency).
Install
Install the plugin as a dev dependency. The README uses pnpm:
- pnpm add -D @7one/vite-agent-poisoner
Minimal config
In vite.config.ts, import agentPoisoner from the package and add it to the plugins array:
- import { agentPoisoner } from "@7one/vite-agent-poisoner";
- export default defineConfig({ plugins: [agentPoisoner()] });
With no options the plugin uses the default vocabulary from the @7one/agent-poisoner-vocabulary package.
Options
The plugin passes every core option through and adds four of its own. Example with your own vocabulary and one javascript-obfuscator option: agentPoisoner({ vocabulary: vocabularyPath, obfuscatorOptions: { renameGlobals: true } }).
- Some commonly used core options: vocabulary (a .yaml, .json or .txt path, or a word list), casing (snake_case, camelCase or mixed), uglify, injectComments, commentFrequency, hexShare and seed.
- The same vocabulary file and the same seed give the same output between builds.
| Option | Default | Meaning |
|---|---|---|
| enabled | true | Turn the plugin off without removing it |
| include / exclude | all .js and .mjs files | Select chunks by name; exclude wins over include |
| concurrency | available parallelism, max 4 | Parallel obfuscation jobs |
| sourcemap | "drop" | "drop" warns and omits maps; "fail" stops the build |
What the plugin does to your config
Three behaviours to know before you build:
- The plugin runs only for vite build, not in dev mode.
- It turns off build.minify, because a minifier that runs afterwards would rename every identifier again. The plugin logs one line saying so.
- If build.sourcemap is on, the plugin drops the source maps of obfuscated chunks and warns. Set sourcemap: "fail" if you want the build to stop instead.
Check the output
After a build, check three things:
- Read the log: each chunk gets one line with the file name and the size before and after, in bytes.
- Open a file in dist and see whether identifier names, numbers and comments were changed.
- Run the build as a real user would and measure the gzip size before release. The README warns the bundle grows, because numbers become expressions and strings are split.
Keep a plain build for debugging: set enabled: false and build again.