Skip to content
David Reed edited this page Nov 20, 2026 · 3 revisions

@sysce/estrogen/vite is a Vite plugin that runs estrogen after the build, over the output directory.

import { defineConfig } from 'vite';
import { pluginEstrogen } from '@sysce/estrogen/vite';

export default defineConfig({
	plugins: [pluginEstrogen()],
});

The named export is pluginEstrogen(options?): Plugin (also the default export). It sets apply: 'build' and enforce: 'post', so it stays out of vite serve and runs after every other plugin. It reads build.outDir from the resolved config and runs estrogen in closeBundle, after the bundle is on disk. If any file fails, the build fails: estrogen fails closed and writes no partial output for a failing file.

Options

Pass the Node API options object to override what the plugin infers. It infers dirs from build.outDir, so you usually set only the per-site data files:

plugins: [pluginEstrogen({ config: 'estrogen.toml' })];
plugins: [
	pluginEstrogen({ names: 'estrogen.names.json', canary: 'canary-list.json' }),
];

See Configuration for the config file.

Dev server

The plugin is build-only, so vite serve and HMR are untouched: estrogen runs on vite build, not in the dev server. A watcher integration that re-runs the vendor and obfuscate step on change, through the Vite dev server, is tracked separately and is not part of this plugin.

Run once

estrogen is not idempotent. The plugin runs once per build, in closeBundle. Do not add it twice, and confirm each build writes a fresh output directory rather than reprocessing one estrogen already rewrote.

Source maps

By default estrogen writes no map and strips sourceMappingURL comments from the chunks it processes. If Vite is set to emit maps, those bundler maps point at pre-obfuscation source and estrogen keeps them out of the served output. For a private debug map, pass sourcemap in the plugin options to write it outside the build. See Source maps.

Clone this wiki locally