Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser Sync and watching multiple folders

Tags:

I'm using browser sync that I installed with NPM to watch my projects as I work on them. Is there a way to get it to watch the root folder and the css folder at once?

like image 570
Caleb Prenger Avatar asked Apr 15 '16 17:04

Caleb Prenger


People also ask

What does Browser Sync do?

Browser synchronization (often simply called sync) is a free cloud service provided by a web browser vendor for sharing settings and data across multiple installs. This is typically used to maintain a consistent browser setup on multiple devices. The user must be logged-in to their account to sync a browser.

How do I change browser browser sync?

In Sublime Text 3 go to Preferences -> Browse Packages... Open 'Browser Sync' folder and edit the browser property in browser_sync_launch. js file. Save this answer.


2 Answers

A bit late, but still, since I needed it I'll post it here for future reference :

Either start browser-sync init and add something like this to the bs-config.js file :

files: ["app/css/style.css", "app/js/*.js"] 

or start browser-sync with following option :

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

This will load current directory AND every other subdirectory.

source : https://www.browsersync.io/docs/options/

like image 176
Antoine Avatar answered Sep 18 '22 13:09

Antoine


To watch multiple files, list the different directories after the --files options, e.g. --files 'directory1' 'directory2/sub'.

An entire npm script command can look like this: browser-sync start --proxy 'localhost:3000' --files 'public' 'src' 'views'

like image 33
criticalJ Avatar answered Sep 21 '22 13:09

criticalJ