• SIS Lab
  • >
  • Note
  • >
  • Hugoプロジェクトでprettierの設定を整える

Hugoプロジェクトでprettierの設定を整える

更新日:2023.07.29 作成日:2023.07.29

インストール

npm install -D --save prettier prettier-plugin-go-template prettier-plugin-tailwindcss

設定ファイル

.prettierrcファイルにprettierの設定を記述する。複数のプラグインも同時に扱えるようだ。

  • prettier-plugin-go-templateは、Go Templateのためのprettierプラグイン
  • prettier-plugin-tailwindcssは、TailwindCSSのためのprettierプラグイン
{
    "plugins": [
        "prettier-plugin-go-template",
        "prettier-plugin-tailwindcss"
    ],
    "overrides": [
        {
            "files": [
                "*.html"
            ],
            "options": {
                "parser": "go-template"
            }
        }
    ]
}

保存時に自動的にフォーマットされるようにした。

{
    "prettier.requireConfig": true,
    "[html]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "editor.formatOnSave": true
  }

Related contents