LoginSignup
2
1

More than 1 year has passed since last update.

Nuxt V3 試してみた

Posted at

10/12にNuxtのV3(ベータ版)が出たので試してみます

実行環境

WSL2+Ubuntuにて試してます。

Nuxt V3プロジェクトの作成

参考:https://v3.nuxtjs.org/getting-started/installation

$ npx nuxi init nuxt3-app

VSCodeで開きます

$ code -r nuxt3-app

ファイルが↓しかありません。

image.png

ファイルを確認

app.vue
<template>
  <div>
    <!-- Remove this component to get started! -->
    <NuxtWelcome />
  </div>
</template>

NuxtWelcomeコンポーネントはどこにあるのか...?

nuxt.config.ts
import { defineNuxtConfig } from 'nuxt3'

export default defineNuxtConfig({
})

⇒ベータ版だからなのか、何も設定がありません

tsconfig.json
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "Node",
    "strict": false,
    "allowJs": true,
    "resolveJsonModule": true,
    "types": [
      "node"
    ]
  }
}
package.json
{
  "private": true,
  "scripts": {
    "dev": "nuxt dev",
    "build": "nuxt build",
    "start": "node .output/server/index.mjs"
  },
  "devDependencies": {
    "nuxt3": "latest"
  }
}

プロジェクト起動

$ cd nuxt3-app
$ npm install
$ npm run dev -- -o

↓のような感じで起動します。

Nuxt CLI v3.0.0-27234503.d5127e9                                                                              07:26:58
                                                                                                              07:26:58
  > Local:    http://localhost:3000/
  > Network:  http://172.30.162.254:3000/

ℹ Vite warmed up in 622ms     
✔ Generated nuxt.d.ts        
✔ Vite server built in 907ms 
✔ Nitro built in 166 ms      

NuxtV2だとビルドで結構時間かかってましたが、Nuxt V3だと2秒以下で完了してます。
ビルドが完了すると自動でhttp://localhost:3000/がブラウザで開きます。
ただ、Nuxt V2と違ってそのままだとlocalhostでアクセスできないようなので、Networkの方でアクセスしてみます
(ベータ版でnuxt.config.tsに何も定義されてないせい?)

image.png

2
1
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
2
1