LoginSignup
3
2

More than 5 years have passed since last update.

BrowserSyncを使って今すぐライブリロードする

Last updated at Posted at 2017-12-27

BrowserSyncはファイルの変更を監視して、変更があれば自動でブラウザをリロードして変更を反映させるためのツール。年の瀬に知ったけどもっと早くちゃんと調べておくべきだった。

クイックスタート

# install
$ npm install -g browser-sync

# start server
$ browser-sync start --proxy http://localhost --files *

これだけ。

仕組み

インストール後、 browser-sync コマンドを実行することでproxyサーバーが立ち上がり、適当なportが割り振られブラウザ上にページが表示される。

--proxy の引数には表示させたいページ、--files の引数には監視したいファイルを指定。ワイルドカードを指定すれば全ファイル対象になる。なお、コマンドを実行したカレントディレクトリ配下にあるファイルのみが対象。

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