1
0

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 3 years have passed since last update.

Vue CLIプロジェクトをGitHub Pagesで公開する方法

Last updated at Posted at 2021-03-13

GitHub Pagesは、gh-pagesを使うと自動で楽ですが、使わなくてもできます。

GitHub Pagesを設定する

Githubで設定します。

https://github.com/[アカウント名]/[リポジトリ名]/settings のGitHub Pagesにある設定を変えます。
Danger Zoneの上辺りにあります。

image.png
mainブランチのdocsを選択して、「Save」ボタンを押します。

Vueプロジェクトのbuild先をdocsディレクトリにする

Vue CLIで作成したプロジェクトのルートにvue.config.jsを作成して、以下のようにします。

module.exports = {
  outputDir: 'docs',
  publicPath: './'
}

Vueプロジェクトをbuildしてリモートへpush

vue.config.jsを保存したら、ローカルでbuildします。

$ npm run build

buildディレクトリにファイルが書き出されるので、ファイルをコミット&mainブランチへpushします。

リモートリポジトリに反映されると、https://[アカウント名].github.io/[リポジトリ名]/で開けるようになります。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?