3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Nuxt 3 with TailwindCSS v3

Last updated at Posted at 2021-12-19

概要

Nuxt3でTailwindCssを設定する方法
TailwindCssはバージョン3系

手順

1. Nuxt3, Tailwindcssをインストール

# Nuxt3をインストール
$ npx nuxi init nuxt3-app

# ディレクトリに移動
$ cd nuxt3-app

# TailwindCSSをインストール
$ npm install -D tailwindcss@latest postcss@latest autoprefixer@latest

# TailwindCSSを初期化
$ npx tailwindcss init

2. taiwind.config.jsを修正

// tailwind.config.js
module.exports = {
  content: [
    './components/**/*.{vue,js}',
    './layouts/**/*.vue',
    './pages/**/*.vue',
    './plugins/**/*.{js,ts}',
    './nuxt.config.{js,ts}',
  ],
};

3. tailwind.cssを作成

/* assets/css/tailwind.css */
@tailwind base;
@tailwind components;
@tailwind utilities;

4. nuxt.config.jsを修正

// nuxt.config.js
import { defineNuxtConfig } from "nuxt3";

export default defineNuxtConfig({
  css: ["@/assets/css/tailwind.css"],
  build: {
    postcss: {
      postcssOptions: {
        plugins: {
          tailwindcss: {},
          autoprefixer: {},
        },
      },
    },
  },
});

完了!!

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?