{"id":20676,"library":"vite-plugin-prettier-format","title":"vite-plugin-prettier-format","description":"Vite plugin that formats output files with Prettier after bundle generation, specifically useful for library mode builds. Version 1.0.0 (initial release) requires Node.js >=18.0.0 || >=20.0.0 and Prettier >=3.0.0 as a peer dependency. It hooks into the closeBundle phase, finds all files in outDir, reads, formats with Prettier using the project's config, and writes back. Unlike other formatting plugins, this one ensures consistent formatting of distribution files during the build process.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/azat-io/vite-plugin-prettier-format","tags":["javascript","vite","prettier","format"],"install":[{"cmd":"npm install vite-plugin-prettier-format","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-prettier-format","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-prettier-format","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency required for formatting; must be >=3.0.0","package":"prettier","optional":false}],"imports":[{"note":"Default export; named import will not work.","wrong":"import { prettierFormat } from 'vite-plugin-prettier-format'","symbol":"prettierFormat","correct":"import prettierFormat from 'vite-plugin-prettier-format'"},{"note":"Package is ESM-only; CommonJS require is not supported.","wrong":"const prettierFormat = require('vite-plugin-prettier-format')","symbol":"vite-plugin-prettier-format","correct":"import prettierFormat from 'vite-plugin-prettier-format'"},{"note":"The plugin is a function that must be called, not passed directly.","wrong":"export default defineConfig({ plugins: [prettierFormat] })","symbol":"plugin","correct":"import prettierFormat from 'vite-plugin-prettier-format'; export default defineConfig({ plugins: [prettierFormat()] })"}],"quickstart":{"code":"// vite.config.js\nimport { defineConfig } from 'vite'\nimport prettierFormat from 'vite-plugin-prettier-format'\n\nexport default defineConfig({\n  plugins: [prettierFormat()],\n  build: {\n    outDir: 'dist',\n  },\n})","lang":"javascript","description":"Minimal Vite config integrating the Prettier format plugin to automatically format output files after build."},"warnings":[{"fix":"Use prettierFormat() in the plugins array.","message":"Plugin function must be called: prettierFormat() not prettierFormat","severity":"gotcha","affected_versions":"1.0.0"},{"fix":"Use only for production builds; for development, rely on editor formatting or a separate Prettier watch command.","message":"Only formats files after bundle; no watch mode support","severity":"gotcha","affected_versions":"1.0.0"},{"fix":"The plugin does nothing during vite dev; ensure it's not required for development.","message":"Only works in build (not serve); skipped during dev server","severity":"gotcha","affected_versions":"1.0.0"},{"fix":"Update Prettier to v3 or later: npm install prettier@latest --save-dev","message":"Requires Prettier >=3.0.0; older versions incompatible","severity":"gotcha","affected_versions":"1.0.0"},{"fix":"If needed, manually filter files or use Prettier's API with ignore support; plugin may skip based on resolveConfig","message":"Does not respect .prettierignore by default","severity":"gotcha","affected_versions":"1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Use: import prettierFormat from 'vite-plugin-prettier-format'","cause":"Importing the plugin as a named export instead of default.","error":"TypeError: prettierFormat is not a function"},{"fix":"Change to ESM import or set type: 'module' in package.json.","cause":"Attempting to use CommonJS require() on an ESM-only package.","error":"Error [ERR_REQUIRE_ESM]: require() of ES Module"},{"fix":"Run: npm install --save-dev prettier@^3.0.0","cause":"Prettier peer dependency not installed.","error":"Cannot find module 'prettier'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}