Search code examples
javascriptreactjsnext.jsformatterprettier

Next.js with prettier formatting


I'm trying to format my next.js project with prettier. In my package.json I've defined this:

"scripts": {
"format": "prettier --write \"**/*.{js, jsx}\"",
},

So my project has a lot of folders:

  • components
  • layouts
  • pages
  • .next

I obviously don't want to run prettier in my .next folder. How can I ignore some folders?


Solution

  • Try this:

    "scripts": {
    "format": "prettier --write \"{,!(.next)/**/}*.{js, jsx}\"",
    },