Browsersync Command Line Usage
First, either install Browsersync globally, or locally to your project (if you're using npm scripts) and then run one of the following commands
$ browser-sync start [options] Start Browsersync
$ browser-sync init Create a configuration file
$ browser-sync reload Send a reload event over HTTP protocol
$ browser-sync recipe [name] Generate the files for a recipe
Command Help (since 2.12.0) ^ TOP
For help running a certain command, type $ browser-sync <command> --help
, for example:
# Get help for the start command only
$ browser-sync start --help
# Get help for the recipe command only
$ browser-sync recipe --help
$ browser-sync start ^ TOP
--server, -s | Run a Local server (uses your cwd as the web root) |
--cwd | Working directory |
--json | If true, certain logs will output as json only |
--serveStatic, --ss | Directories to serve static files from |
--port | Specify a port to use |
--proxy, -p | Proxy an existing server |
--ws | Proxy mode only - enable websocket proxying |
--browser, -b | Choose which browser should be auto-opened |
--watch, -w | Watch files |
--ignore | Ignore patterns for file watchers |
--files, -f | File paths to watch |
--index | Specify which file should be used as the index page |
--plugins | Load Browsersync plugins |
--extensions | Specify file extension fallbacks |
--startPath | Specify the start path for the opened browser |
--single | If true, the connect-history-api-fallback middleware will be added |
--https | Enable SSL for local development |
--directory | Show a directory listing for the server |
--tunnel | Use a public URL |
--open | Choose which URL is auto-opened (local, external or tunnel), or provide a url |
--cors | Add Access Control headers to every request |
--config, -c | Specify a path to a configuration file |
--host | Specify a hostname to use |
--listen | Specify a hostname bind to (this will prevent binding to all interfaces) |
--logLevel | Set the logger output level (silent, info or debug) |
--reload-delay | Time in milliseconds to delay the reload event following file changes |
--reload-debounce | Restrict the frequency in which browser:reload events can be emitted to connected clients |
--ui-port | Specify a port for the UI to use |
--watchEvents | Specify which file events to respond to |
--no-notify | Disable the notify element in browsers |
--no-open | Don't open a new browser window |
--no-snippet | Disable the snippet injection |
--no-online | Force offline usage |
--no-ui | Don't start the user interface |
--no-ghost-mode | Disable Ghost Mode |
--no-inject-changes | Reload on every file change |
--no-reload-on-restart | Don't auto-reload all browsers following a restart |
# Examples
# Start a server from the `app` directory, watching all files
$ browser-sync start --server 'app' --files 'app'
# As above, but with version >= 2.23.0
$ browser-sync app -w
# Start a server from the `app` & `.tmp` directories (short hand)
# (requires 2.12.1)
$ browser-sync start -s 'app' '.tmp' -f 'app' '.tmp'
# As above, but with version >= 2.23.0
$ browser-sync 'app' '.tmp' -w
# Proxy a PHP app + serve static files & watch them
$ browser-sync start --proxy 'mylocal.dev' --serveStatic 'public' --files 'public'
# As above, but with version >= 2.23.0
$ browser-sync 'http://mylocal.dev' 'public' -w
# Start Browsersync from a config file
$ browser-sync start --config 'conf/browser-sync.js'
# Start Browsersync from a config file with overriding flags
$ browser-sync start --config 'conf/browser-sync.js' --port 4000
$ browser-sync recipe ^ TOP
--output, -o | Specify an output directory |
# Examples
# List all available recipes
$ browser-sync recipe ls
# Copy files for gulp.sass recipe
$ browser-sync recipe 'gulp.sass'
# Copy files for gulp.sass recipe into custom output directory
$ browser-sync recipe 'gulp.sass' -o 'my-project'
$ browser-sync reload ^ TOP
--files, -f | File paths to reload |
--port, -p | Target a running instance by port number |
--url, -u | Provide the full the url to the running Browsersync instance |
# Examples
# Reload assuming standard address of http://localhost:3000
$ browser-sync reload
# Reload all css files, where Browsersync is running at http://localhost:4000
$ browser-sync reload --port 4000 --files="*.css"
# Reload all css files, where Browsersync is running at https://localhost:3000
$ browser-sync reload --url https://localhost:3000 --files="*.css"
$ browser-sync init ^ TOP
$ browser-sync init
Jump to...