Skip to content

SeiyaIwabuchi/Nextjs-ts-setup-guide

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

nextjsの始め方

project-root
├ pages
│ └ index.js(option)
├ .gitignore
└ package.json
  1. node.jsを入れる!
  2. プロジェクトディレクトリを作る
  3. npm init
  4. npm install next react react-dom
  5. package.jsonの編集
  6. scriptを以下のように書き換える
"scripts": {
  "dev": "next dev",
  "build": "next build",
  "start": "next start"
}
  1. mainを削除
  2. pagesディレクトリを作成
  3. npx next build でビルド
  4. npx next start でサーバーの起動
  5. .vscode/にlaunch.jsonやtasks.jsonを作成
  • launch.json
    {
     "version": "0.2.0",
     "configurations": [
         {
             "type": "node",
             "request": "attach",
             "name": "debugger",
             "skipFiles": [
                 "<node_internals>/**"
             ],
             "port": 9229,
             "preLaunchTask" : "npm: dev - nextjs-blog"
         }
     ]
    }
    • tasks.json
    {
    "version": "2.0.0",
    "tasks": [
     {
       "type": "npm",
       "script": "build",
       "path": "nextjs-blog/",
       "group": "build",
       "problemMatcher": [],
       "label": "npm: build - nextjs-blog",
       "detail": "next build"
     },
     {
       "type": "npm",
       "script": "dev",
       "path": "nextjs-blog/",
       "problemMatcher": [],
       "label": "npm: dev - nextjs-blog",
       "detail": "next dev",
       "group": {
         "kind": "build",
         "isDefault": true
       },"dependsOn" : [
         "npm: build - nextjs-blog"
       ]
     }
    ]
    }
  1. .gitignoreを作成
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel

typescript対応

  1. npm install --save-dev @types/react
  2. npx tsc --init

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published