Fl4m3Ph03n1x
VSCode Format on save breaks app.css
Background
I am using VSCode to do my Phoenix app, however, when modifying the app.css I realized the formatting was literally breaking my code. Specifically, “Format on Save”:

As you can see, hover:ring-gray becomes hover: ring-gray, which is invalid and breaks the file.
Questions
Other than disabling VSCode’s format on save, does someone know how else I can fix this?
Marked As Solved
Fl4m3Ph03n1x
Solution
While I still don’t know how to fix this issue in VSCode itself, I did find a workaround for this problem.
My solution was installing a new extension, namely:
Then you need to edit your VSCode settings and add this:
"files.associations": {
"*.css": "tailwindcss"
},
"editor.quickSuggestions": {
"strings": true
}
With these changes, the extension will now be responsible for formatting your css files, and because it understands that hover:ring-gray is different than hover: ring-gray it won’t change it and the app.css file won’t break.
I am not sure if this is the only solution, but it is the only solution I found.
Also Liked
LostKobrakai
It’s the only correct one imo. The file can have a .css extension, but the syntax for tailwinds @apply isn’t valid css. So it’s reasonable for any css formatter to break. You need something understanding the additional tailwind syntax to ensure formatting works correctly.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








