十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。

BrowserSync 測試多個平台

上一篇 / 下一篇  2015-03-21 09:50:47 / 个人分类:测试工具相关

文章来源
  • 文章来源:【译文】

V i(d}-b@C%x0
  1. 1. Install Node.js

    BrowserSync is a module for Node.js, a platform. for fast network applications. There are convenient installers for MacOS, Windows and Linux.51Testing软件测试网UI p3Sy7|

  2. 2. Install BrowserSync

    The Node.js package manager (npm) is used to install BrowserSync from a repository. Open a terminal window and run the following command:

    Wu,Lt#h0
    npm install -g browser-sync

    You’re telling the package manager to download the BrowserSync files and install them globally so they’re available to all your projects.51Testing软件测试网 l8xV @-L3iHZp

  3. 3. Start BrowserSync

    A basic use is to watch all CSS files in the css directory and update connected browsers if a change occurs. Navigate your terminal window to a project and run the appropriate command:

    :eKQ%V@n0f \E0

    Static sites

    If you’re only using .html files, you’ll need to use the server mode. BrowserSync will start a mini-server and provide a URL to view your site.51Testing软件测试网)Z ltw_!wv

    browser-sync start --server --files "css/*.css"

    Dynamic sites

    If you’re already running a local server with PHP or similar, you’ll need to use the proxy mode. BrowserSync will wrap your vhost with a proxy URL to view your site.51Testing软件测试网CE4S`h&P ed$j)i

    browser-sync start --proxy "myproject.dev" --files "css/*.css"


[8R)V C/i051Testing软件测试网g/o^#vvaA E

BrowserSync 是用 node.js 寫的工具,可以同時測試一堆 device,修改後不用按 reload,印象中已經有套件可以做類似的事情?51Testing软件测试网&tmG[ B.J

一般用 npm 裝就可以了:51Testing软件测试网&Mn,o9lF-q#m

npm install browser-sync

最簡單的方法是直接執行 browser-sync,執行後會出現像這樣的訊息:51Testing软件测试网/F3y yE$? i1Y

<script. src='//192.168.1.1:3000/socket.io/socket.io.js'></script>
<script>var ___socket___ = io.connect('http://192.168.1.1:3000');</script>
<script. src='//192.168.1.1:3001/client/browser-sync-client.0.6.0.js'></script>

把這段程式碼貼到 body 的最後面就可以了,當 BrowerSync 偵測到檔案有更新時會透過 server push 機制重刷頁面。

-W2bD1k4P g)p\0

另外,也可以產生 bs-config.js 修改設定:51Testing软件测试网KXxnPz

browser-sync --init

更完整的說明可以從「Options」這頁找到。

/N:uk,[m0

TAG: BrowserSync

 

评分:0

我来说两句

Open Toolbar