Last active
January 28, 2025 16:21
-
-
Save cecilemuller/fcfe7b09764ca40fa435b540e59d9a76 to your computer and use it in GitHub Desktop.
Vite Plugin: apply Prettier to HTML output using `transformIndexHtml`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { PluginOption } from "vite"; | |
import { format } from "prettier"; | |
export function plugin(): PluginOption { | |
return { | |
name: "example", | |
transformIndexHtml: async (html) => format(html, { | |
// https://prettier.io/docs/en/options.html | |
parser: "html", | |
htmlWhitespaceSensitivity: "ignore" | |
}) | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment