1. Home
  2. Blog
  3. Add agent-poisoner to Vite

Adding agent-poisoner to a Vite project

This post shows how to add the @7one/vite-agent-poisoner plugin to a Vite project: install, config, options and checking the result. Everything below comes from the package docs and source. If you are not sure what the tool is, read the introduction first.

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.
Options added by the plugin
OptionDefaultMeaning
enabledtrueTurn the plugin off without removing it
include / excludeall .js and .mjs filesSelect chunks by name; exclude wins over include
concurrencyavailable parallelism, max 4Parallel 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.

Frequently asked questions

Does the plugin run during vite dev?
No. The plugin declares apply: build, so it runs only for vite build.
Why is build.minify turned off?
Because a minifier running after the obfuscator would rename every identifier again. The plugin turns it off and logs that. If you already set build.minify: false, the plugin changes nothing.
Can I use source maps?
No. Source maps do not survive obfuscation. By default the plugin drops them and warns, or stops the build if you set sourcemap: "fail".
How do I switch it off for a while?
Set enabled: false. The plugin stays in the config but does nothing, and build.minify is left alone.

Need the full reference?

Each package README is in https://github.com/71zone/agent-poisoner. For the internals, read how it works. If you want someone to set it up and check it for your project, contact 71.zone.

Contact us

Calling or messaging is fastest. Or pick an open time and we call you then.

Phone and WhatsApp0949 462 207

We reply within 1 working day.

Call now WhatsApp