BrowserSync の起動が遅くてイライラが半端無かったので、debug ログを表示してみたところ下記の3箇所で詰まっていました。
[BS] [debug] -> Starting Step: Finding an empty port
[BS] [debug] Found a free port: 3000
[BS] [debug] Setting Option: port - 3000
[BS] [debug] + Step Complete: Finding an empty port
[BS] [debug] -> Starting Step: Checking online status
[BS] [debug] Resolved www.google.com, setting online: true
[BS] [debug] Setting Option: online - true
[BS] [debug] + Step Complete: Checking online status
[BS] [UI] Starting Step: Finding a free port
[BS] [UI] Step Complete: Finding a free port
[BS] [debug] -> Starting Step: Finding an empty port
は BrowserSync のサーバのための空きポートを探しています。
port:8080
のようにポートを指定すれば消えるかと思ったのですが、消えませんでした。port
の設定は使用するポートを固定するわけではなく、空きポートの検出をどこから行なうかの設定のようです。指定したポートが使用されているとその次のポート(例えば 8081
)がチェックされます。
とりあえず、なるべく空いてそうなポートを指定するのが良さそうです。
[BS] [debug] -> Starting Step: Checking online status
はホストがオンラインかどうかを調べています。
xio
や tunnel
を使わないなら online:false
で良いです。
[BS] [UI] Starting Step: Finding a free port
は BrowserSync の UI のための空きポートを探しています。
UI が必要ないなら ui:false
で良いです。
var bs = require("browser-sync").create();
bs.init({
logLevel: "debug",
files: ["web/*.html"],
server: "./web",
open: true,
port: 16845,
online: false,
ui: false
});