{"id":20466,"library":"prettier-webpack-plugin","title":"Prettier Webpack Plugin","description":"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.","status":"maintenance","version":"1.2.0","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/hawkins/prettier-webpack-plugin","tags":["javascript","prettier","webpack","plugin"],"install":[{"cmd":"npm install prettier-webpack-plugin","lang":"bash","label":"npm"},{"cmd":"yarn add prettier-webpack-plugin","lang":"bash","label":"yarn"},{"cmd":"pnpm add prettier-webpack-plugin","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency: core formatting engine","package":"prettier","optional":false},{"reason":"Peer dependency: v4.2+ required","package":"webpack","optional":false}],"imports":[{"note":"Package is CommonJS only; no ESM export.","wrong":"import PrettierPlugin from 'prettier-webpack-plugin';","symbol":"default export","correct":"const PrettierPlugin = require('prettier-webpack-plugin');"},{"note":"No .default; direct require exports the constructor.","wrong":"new PrettierPlugin.default({})","symbol":"Plugin instantiation","correct":"new PrettierPlugin({ /* options */ })"},{"note":"No type definitions; use @types if needed. Avoid star import due to CJS.","wrong":"import * as PrettierPlugin from 'prettier-webpack-plugin';","symbol":"TypeScript usage","correct":"const PrettierPlugin = require('prettier-webpack-plugin');"}],"quickstart":{"code":"const PrettierPlugin = require('prettier-webpack-plugin');\nconst path = require('path');\n\nmodule.exports = {\n  entry: './src/index.js',\n  output: {\n    path: path.resolve(__dirname, 'dist'),\n    filename: 'bundle.js',\n  },\n  plugins: [\n    new PrettierPlugin({\n      printWidth: 80,\n      tabWidth: 2,\n      useTabs: false,\n      semi: true,\n      encoding: 'utf-8',\n      extensions: ['.js', '.ts'],\n      configFile: '.prettierrc',\n    }),\n  ],\n};","lang":"javascript","description":"Webpack config using prettier-webpack-plugin with Prettier options, custom extensions, and config file."},"warnings":[{"fix":"Upgrade to prettier-webpack-plugin@1 and ensure webpack@^4.2.0 is installed.","message":"Webpack 4 support requires version 1.x; version 0.x only supports Webpack 3.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Ensure files are committed before bundling; consider using prettier-webpack-loader for in-memory only.","message":"Plugin overwrites original source files (not in-memory). Use version control to avoid loss.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Migrate to prettier-webpack-loader or configure Prettier via IDE/CI.","message":"Package is unmaintained since 2018; no security updates or compatibility with modern Webpack/Prettier.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Review Prettier options before specifying plugin-specific ones; use configFile to externalize.","message":"Prettier options are passed directly; plugin-specific options (encoding, extensions, configFile) may conflict if Prettier adds same-named options.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'npm install --save-dev prettier prettier-webpack-plugin' or 'yarn add --dev prettier prettier-webpack-plugin'.","cause":"Package not installed or mismatched version.","error":"Cannot find module 'prettier-webpack-plugin'"},{"fix":"Install prettier: 'npm install prettier' or add to devDependencies.","cause":"Peer dependency prettier missing.","error":"Error: Plugin could not be instantiated. Is Prettier installed?"},{"fix":"Use 'const PrettierPlugin = require('prettier-webpack-plugin');' instead of import.","cause":"Using import instead of require (ESM vs CJS).","error":"TypeError: prettierWebpackPlugin is not a constructor"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}