Vojtěch Struhár

Posted on October 28, 2024 | #astro

Prettier Astro in WebStorm

WebStorm recently got Astro support, which is very sweet. But I want to use Prettier as my formatter to stay consistent parts of the project I made in VS Code.

Prettier doesn’t support .astro files out of the box. You have to install a plugin for that:

pnpm i -D prettier prettier-plugin-astro

Then you have to enable the astro plugin. For my .prettierrc the line looks like this:

{
  "plugins": ["prettier-plugin-astro"]
}

Now check the Settings > Tools > Actions on Save > Run Prettier option. I also went with the manual prettier configuration option and added json to the file extensions list to sweeten the deal.

Manual prettier configuration

Read next → Astro Could not transform image