Installation and use of Browsersync

Source: Internet
Author: User

Browsersync is really a prerequisite artifact, browser Sync tool. In short, when you save the file browser automatically refresh the page, save the manual link, greatly save the development time, this tool is based on Nodejs, can be installed through NPM, not verbose

After installing node, install Browsersync via NPM:

NPM install-g Browser-sync

Then, you can start using it. Open the console to the directory where the project is located, and then enter a command like this:

Browser-sync start--server--files "Css/*.css"

This command is used for a purely static site, which is the case for only some. html files. The following--files "Css/*.css" refers to a file in the listening CSS directory with a suffix named. css. Please note that the start--server in this command, which is actually browsersync to start a small server.

If it is a dynamic site, the proxy mode is used. For example, PHP site, has established a local server such as http://localhost:8080, this will be the command:

Browser-sync start--proxy "localhost:8080"--files "Css/*.css"

Browsersync will provide a new address (if not occupied, http://localhost:3000) for access.

If you simply want to listen to the entire project, you can write it like this:

Browser-sync start--server  --files "* *"

In the console, try to enter only:

Browser-sync

You will see a complete console command guide for Browsersync. which can be seen with this command:

Browser-sync Init

Run it and a profile bs-config.js will be generated in the current directory.

Modify this file by referencing the official documentation and then run

Browser-sync start--config bs-config. js

will run with the full configuration information of Bs-config.js Browsersync
The following is a temporary screenshot of my runtime

3001 Port is the back office address, inside can open and close some functions, want to terminate the current directory, with CTRL + C command interrupt can, empty with the CLS command
Also can use this tool through Gulp, Gulp is now popular automation tool, but Browsersync does not have Gulp plug-in version, because do not need.
Browsersync has its own independent API, registering it as a task of gulp and sending it to the official portal

Installation and use of Browsersync

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.