Registry / devops / prettier-webpack-plugin

prettier-webpack-plugin

JSON →
library1.2.0jsnpmunverified

Automatically formats source files with Prettier during Webpack bundling. Version 1.2.0 supports Webpack 4 (peer dep webpack@^4.2.0) and Prettier ^1.0.0. The plugin reads all dependency files, processes matching extensions (defaults based on Prettier's getSupportInfo), and overwrites them. Key differentiator from a loader: overwrites files directly, not transforming in-memory. Limited to Node.js with Webpack; not maintained since 2018. Alternatives: prettier-webpack-loader for in-memory formatting, or eslint-webpack-plugin with prettier rules for broader linting.

npm install prettier-webpack-plugin
INSTALL
IMPORT
SIG · PRETTIER-WEBPACK-P
P
prettier-webpack-plugin
devopsjavascriptv1.2.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default export
const PrettierPlugin = require('prettier-webpack-plugin');
import PrettierPlugin from 'prettier-webpack-plugin';
Package is CommonJS only; no ESM export.
Plugin instantiation
new PrettierPlugin({ /* options */ })
new PrettierPlugin.default({})
No .default; direct require exports the constructor.
TypeScript usage
const PrettierPlugin = require('prettier-webpack-plugin');
import * as PrettierPlugin from 'prettier-webpack-plugin';
No type definitions; use @types if needed. Avoid star import due to CJS.

Webpack config using prettier-webpack-plugin with Prettier options, custom extensions, and config file.

const PrettierPlugin = require('prettier-webpack-plugin'); const path = require('path'); module.exports = { entry: './src/index.js', output: { path: path.resolve(__dirname, 'dist'), filename: 'bundle.js', }, plugins: [ new PrettierPlugin({ printWidth: 80, tabWidth: 2, useTabs: false, semi: true, encoding: 'utf-8', extensions: ['.js', '.ts'], configFile: '.prettierrc', }), ], };
Debug
Known issues
breakingWebpack 4 support requires version 1.x; version 0.x only supports Webpack 3.
fix
Upgrade to prettier-webpack-plugin@1 and ensure webpack@^4.2.0 is installed.
affects: <1.0.0
gotchaPlugin overwrites original source files (not in-memory). Use version control to avoid loss.
fix
Ensure files are committed before bundling; consider using prettier-webpack-loader for in-memory only.
affects: >=0.0.0
deprecatedPackage is unmaintained since 2018; no security updates or compatibility with modern Webpack/Prettier.
fix
Migrate to prettier-webpack-loader or configure Prettier via IDE/CI.
affects: >=0.0.0
gotchaPrettier options are passed directly; plugin-specific options (encoding, extensions, configFile) may conflict if Prettier adds same-named options.
fix
Review Prettier options before specifying plugin-specific ones; use configFile to externalize.
affects: >=0.0.0
Errors
Common errors & fixes
Cannot find module 'prettier-webpack-plugin'
Package not installed or mismatched version.
fix
Run 'npm install --save-dev prettier prettier-webpack-plugin' or 'yarn add --dev prettier prettier-webpack-plugin'.
Error: Plugin could not be instantiated. Is Prettier installed?
Peer dependency prettier missing.
fix
Install prettier: 'npm install prettier' or add to devDependencies.
TypeError: prettierWebpackPlugin is not a constructor
Using import instead of require (ESM vs CJS).
fix
Use 'const PrettierPlugin = require('prettier-webpack-plugin');' instead of import.
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency: core formatting engine
webpackrequiredPeer dependency: v4.2+ required
Agent activity
10 hits · last 30 days
node
10
Resources
prettier-webpack-plugin — npm install prettier-webpack-plugin · libregistry