Skip to content

Instantly share code, notes, and snippets.

View sparker888's full-sized avatar
:octocat:

Stephen Parker sparker888

:octocat:
View GitHub Profile
@gma
gma / vscode-auto-format-astro-on-save.md
Last active April 26, 2022 11:08
Configuring VS Code to format Astro files with Prettier

Configuring VS Code to format Astro files with Prettier

There's an Astro extension for VS Code that provides syntax highlighting, completion and emmet support, but as of April 2022 it doesn't support auto-formatting.

There's a prettier plugin for Astro. We can install that and then configure VS Code to run Prettier when we save a file.

Installing prettier

Let's start by installing prettier and the Astro plugin into our project:

npm install -D prettier prettier-plugin-astro