← 返回命令列表

Linux command

browser-sync 命令

网络

需要网络或远程资源。

常用示例

Start server in current directory

browser-sync start --server

Start server from specific directory

browser-sync start --server [app]

Start server watching all files

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

Watch specific file types

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

Proxy existing server

browser-sync start --proxy "[localhost:8080]"

Create configuration file

browser-sync init

Send reload event

browser-sync reload

Start with custom port

browser-sync start --server --port [3000]

说明

browser-sync is a development tool that keeps multiple browsers and devices synchronized while building websites. It watches files for changes and either injects CSS/images or triggers full page reloads. The tool works by injecting an asynchronous script tag after the body tag during initial requests, enabling real-time synchronization across all connected browsers.

参数

--server _directory_
Serve files from specified directory
--proxy _url_
Proxy an existing server
--files _pattern_
File patterns to watch for changes
--port _number_
Port to use (default: 3000)
--https
Enable HTTPS for localhost development
--no-open
Don't open browser on start
--browser _name_
Browser to open (chrome, firefox, etc.)
--config _file_
Path to configuration file
--reload-delay _ms_
Milliseconds to wait before reloading

FAQ

What is the browser-sync command used for?

browser-sync is a development tool that keeps multiple browsers and devices synchronized while building websites. It watches files for changes and either injects CSS/images or triggers full page reloads. The tool works by injecting an asynchronous script tag after the body tag during initial requests, enabling real-time synchronization across all connected browsers.

How do I run a basic browser-sync example?

Run `browser-sync start --server` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --server _directory_ do in browser-sync?

Serve files from specified directory