Registry / devops / vite-plugin-prettier-format

vite-plugin-prettier-format

JSON →
library1.0.0jsnpmunverified

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.

npm install vite-plugin-prettier-format
INSTALL
IMPORT
SIG · VITE-PLUGIN-PRETTI
V
vite-plugin-prettier-format
devopsjavascriptv1.0.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.

prettierFormat
import prettierFormat from 'vite-plugin-prettier-format'
import { prettierFormat } from 'vite-plugin-prettier-format'
Default export; named import will not work.
vite-plugin-prettier-format
import prettierFormat from 'vite-plugin-prettier-format'
const prettierFormat = require('vite-plugin-prettier-format')
Package is ESM-only; CommonJS require is not supported.
plugin
import prettierFormat from 'vite-plugin-prettier-format'; export default defineConfig({ plugins: [prettierFormat()] })
export default defineConfig({ plugins: [prettierFormat] })
The plugin is a function that must be called, not passed directly.

Minimal Vite config integrating the Prettier format plugin to automatically format output files after build.

// vite.config.js import { defineConfig } from 'vite' import prettierFormat from 'vite-plugin-prettier-format' export default defineConfig({ plugins: [prettierFormat()], build: { outDir: 'dist', }, })
Debug
Known issues
gotchaPlugin function must be called: prettierFormat() not prettierFormat
fix
Use prettierFormat() in the plugins array.
affects: 1.0.0
gotchaOnly formats files after bundle; no watch mode support
fix
Use only for production builds; for development, rely on editor formatting or a separate Prettier watch command.
affects: 1.0.0
gotchaOnly works in build (not serve); skipped during dev server
fix
The plugin does nothing during vite dev; ensure it's not required for development.
affects: 1.0.0
gotchaRequires Prettier >=3.0.0; older versions incompatible
fix
Update Prettier to v3 or later: npm install prettier@latest --save-dev
affects: 1.0.0
gotchaDoes not respect .prettierignore by default
fix
If needed, manually filter files or use Prettier's API with ignore support; plugin may skip based on resolveConfig
affects: 1.0.0
Errors
Common errors & fixes
TypeError: prettierFormat is not a function
Importing the plugin as a named export instead of default.
fix
Use: import prettierFormat from 'vite-plugin-prettier-format'
Error [ERR_REQUIRE_ESM]: require() of ES Module
Attempting to use CommonJS require() on an ESM-only package.
fix
Change to ESM import or set type: 'module' in package.json.
Cannot find module 'prettier'
Prettier peer dependency not installed.
fix
Run: npm install --save-dev prettier@^3.0.0
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
prettierrequiredPeer dependency required for formatting; must be >=3.0.0
Agent activity
13 hits · last 30 days
node
12
Resources
vite-plugin-prettier-format — npm install vite-plugin-prettier-format · libregistry