Next.js (App Router & Pages Router)
In Next.js projects, unpeek strictly targets `.next/static/chunks` (discovering entries from `.next/build-manifest.json` and exempting `globalThis.TURBOPACK.push` headers) while leaving `.next/server` completely untouched. Async split chunks resolve cleanly even before the entry shield initializes.
Both `postbuild` CLI execution and the `unpeek/unplugin` adapter are supported.
{
"scripts": {
"dev": "next dev",
"build": "next build",
"postbuild": "unpeek protect"
},
"devDependencies": {
"unpeek": "^1.12.0"
}
}import unpeek from "unpeek/unplugin";
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack(config, { dev, isServer }) {
if (!dev && !isServer) {
config.plugins.push(
unpeek.webpack({
deterrentMode: "passive",
})
);
}
return config;
},
};
export default nextConfig;Vite & Rollup (CLI or unplugin)
For Vite applications, `unpeek/vite` hooks into `enforce: 'post'` `generateBundle` (after esbuild minification) and automatically wires `worker.plugins` for Web Worker bundles.
import { defineConfig } from "vite";
import unpeek from "unpeek/vite";
export default defineConfig({
build: {
sourcemap: true, // Extracted to .unpeek-maps/ during postbuild
},
plugins: [
unpeek({
seed: 0x9fa21b,
minStringLength: 4,
injectRuntimeShield: true,
deterrentMode: "passive",
}),
],
});Webpack, Rspack & Vanilla JS Targets
Webpack 5 and Rspack plugins hook into `processAssets` (`PROCESS_ASSETS_STAGE_OPTIMIZE_INLINE`), esbuild runs in `build.onEnd` (`write: false` and `write: true`), and Rollup handles hash placeholders in `renderChunk`. Service Workers (`sw.js`) and Web Workers (`*.worker.js`) are excluded by default unless `target: 'worker'` is set.
import unpeek from "unpeek/unplugin";
export default {
mode: "production",
plugins: [
unpeek.webpack({
deterrentMode: "passive",
minStringLength: 5,
}),
],
};