Webpack + patch-spec

If you need to keep webpack: true in nest-cli.json, apply docs files at build time instead of at runtime.

Why this is necessary

With "webpack": true in nest-cli.json (the documented default for monorepos with multiple apps), the DocfyModule runtime discovery doesn't work: webpack bundles everything into a single bundle and never populates require.cache with one entry per original source file, which is what that discovery depends on. This is architectural, not a fixable bug. See strict mode & webpack.

Pipeline

bash
# 1. Start the app just to get the live /api-json
node dist/main.js &

# 2. Generate an OpenAPI document with all docs files already applied
npx nestjs-docfy patch-spec --spec http://localhost:3000/api-json --out openapi.patched.json

# 3. Serve the patched document via DocfyUiModule
#    DocfyUiModule.setup('/docs', app, { staticSpecPath: './openapi.patched.json' });

Call DocfyUiModule.setup() before SwaggerModule.setup() so that the static /api-json takes precedence over the live one.