64
60

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

BrowserSyncで勝手に立ち上がるブラウザを変更したり、localhost:8888とかでなく、192.168.1.1:8888とかで立ち上げちゃいたいときのGulp設定

Last updated at Posted at 2014-10-21

BrowserSyncにはいろいろオプションがある

APIオプションにいろいろ書いてある。ちょろっと見ておくと吉でしょう。

ここではgulpの設定で書いてますが、gruntでもだいたい同じなんじゃないかな!ウェーイ!!

勝手に立ち上がるブラウザを変更するとき

gulpfile.coffee
gulp.task 'browser-sync', ->
  browserSync(
    port: 8888
    browser: 'Google Chrome Canary'  # ←ここ。winのときはこれでは動かんので、ググると吉。
    server: {
      baseDir: "./public"
    }
  )

localhost:8888じゃなくて自分のIPで立ち上げる

スマホで確認するときにいちいちipに打ち替えるのがめんどうなので、こちらで!

npmでmy-ip gulp-openをインストール

npm install my-ip gulp-open -D
gulpfile.coffee
ip = require('my-ip')(null, false) # ←自分のローカルIPが入る
PORT = 8888

gulp.task "open", ->
  options =
    url: "http://#{ip}:#{PORT}"
    app: "Google Chrome Canary" # winのときはこれでは動かんので、ググると吉。

  gulp.src("./gulpfile.coffee").pipe open("", options)
  return


# gulp server でビルド+browser sync → openする
gulp.task 'server', (callback) -> runSequence(['browser-sync', 'build'], ['open', 'watch'], callback)

だいたいこんな流れでウェーイ!!!フゥーーー!!!!

64
60
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?