Nextjs项目部署GithubPages

0 阅读1分钟

1.开启静态输出

根据官网进行配置:

image.pngnext.config.js文件里增加:

output:'export'

2.项目安装gh-pages

yarn add gh-pages

package.json文件中增加下面部署命令:

 "homepage": "./",
 "scripts": {
    "deploy": "gh-pages -d build"
  },

3.命令执行

yarn build // 执行之后项目会生成out文件夹
yarn deploy // 执行之后,远程仓库会多出一个gh-pages分支

image.png

4.github部署

image.png