LoginSignup
60
46

More than 5 years have passed since last update.

npm run deploy で GitHub Pages にお手軽デプロイ

Last updated at Posted at 2016-03-04

gh-pages

npm run deploy とコマンドラインで打つだけで GitHub Pages にデプロイするために、 gh-pages を使う。

インストール:

npm install gh-pages --save-dev

使い方

package.json の scripts を以下のように書く

"scripts": {
    "deploy": "gh-pages -d dist"
  }

dist が GitHub Pages として公開したいディレクトリ。
ここを自分に公開したいディレクトリを指定する。
これだけで dist ディレクトリが gh-pages ブランチとして GitHub に Push される。

これで npm run deploy ができるようになる。

実例

現在開発中の starhoshi/AlcatrazSearchnpm run deploy でデプロイしている。
package.json は以下のように設定している。

  "scripts": {
    "dev-server": "node webpack/dev-server.js",
    "build": "NODE_ENV=production webpack --config webpack/webpack-production.config.js --progress --profile --colors",
    "deploy": "npm run build && gh-pages -d build/public",
    "test": "./node_modules/.bin/typings install && ./node_modules/.bin/tsc && ./node_modules/.bin/mocha  --require test-setup --recursive ./dist/**/__spec__/**/*-spec.js"
  }

buildbuild/publicwebpack でごにょごにょしたファイルが設置され、 gh-pages -d build/public を行い GitHub Pages にデプロイしている。

60
46
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
60
46