Created
April 15, 2024 07:35
-
-
Save cecilemuller/7a8eae6091feb05aa84b413118a1a45c to your computer and use it in GitHub Desktop.
Vite Plugin: Prettier
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"; | |
/** | |
* Format HTML pages using Prettier. | |
*/ | |
export function prettierPlugin(): PluginOption { | |
return { | |
name: "prettier", | |
transformIndexHtml: { | |
order: "pre", | |
handler: async (html: string) => { | |
const formatted = await format(html, {parser: "html"}); | |
return formatted; | |
} | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment