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