A Webpack plugin that enables bundling pino v7+ logger with webpack-generated bundles. Version 2.0.0 supports webpack 5 and requires Node >=12.13.0. It works by extracting pino's worker threads (thread-stream, pino-worker, pino-pipeline-worker, pino-file) into separate bundle files, which must be deployed alongside the main bundle. The plugin allows specifying extra transports like pino-pretty. Key differentiator: it's the official way to use pino in webpack projects, addressing the incompatibility between pino's Node.js Worker Threads architecture and webpack's bundling. Ships TypeScript types.
npm install pino-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Basic webpack configuration that includes pino-webpack-plugin with a pino-pretty transport.
Ensure all generated files are included in deployment. Do not assume only the main bundle file is needed.
Always specify every pino transport used in your code. For example: `transports: ['pino-pretty', 'pino/file']`. Note: `pino/file` is always included automatically.
Upgrade Node to >=12.13.0 and webpack to >=5.61.0.
Ensure pino version is v7 or higher. Check with `npm list pino`.
Accept the multi-file output. Do not attempt to inline or ignore these files.
Ensure that the webpack output directory contains all generated files: thread-stream.js, pino-worker.js, pino-pipeline-worker.js, pino-file.js. Include them in deployment.
Use `import { PinoWebpackPlugin } from 'pino-webpack-plugin'` (ESM) or `const { PinoWebpackPlugin } = require('pino-webpack-plugin')` (CommonJS).Add `transports` option array to the constructor, e.g., `new PinoWebpackPlugin({ transports: ['pino-pretty'] })`.Do not import the generated worker files manually. The plugin handles them automatically.
Upgrade webpack to version 5.61.0 or higher.