十五年测试老手,长期负责WEB\APP 项目测试,目前主要负责团队管理工作。
BrowserSync 測試多個平台
上一篇 /
下一篇 2015-03-21 09:50:47
/ 个人分类:测试工具相关
51Testing软件测试网G1}9?a/e })r
d]
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.
w,Pnl'u;Zk2BP,[*S a02. 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:
'vbLV kC;w0npm 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软件测试网8}UC2vJ
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:
v.c*`IpD#J3HR5@{8@0Static 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软件测试网:oZ\Jv&y~'A
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软件测试网A]$o0UIu ~I
browser-sync start --proxy "myproject.dev" --files "css/*.css"
3M,ZZ"K#N%Nk]0
'Q-P@h6Bn!A0B ~0BrowserSync 是用 node.js 寫的工具,可以同時測試一堆 device,修改後不用按 reload,印象中已經有套件可以做類似的事情?
&Md'u!i(x0一般用 npm 裝就可以了:
Q A z&bu {e0npm install browser-sync
最簡單的方法是直接執行 browser-sync
,執行後會出現像這樣的訊息:
$W(q!w ` C7?sLg0<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 機制重刷頁面。51Testing软件测试网 X;NzPwt
另外,也可以產生 bs-config.js 修改設定:51Testing软件测试网:S&{i)P~U j)}A*mF
browser-sync --init
更完整的說明可以從「Options」這頁找到。51Testing软件测试网ZY7vkp9VF
收藏
举报
TAG:
BrowserSync