Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 1.17 KB

Browsersync.md

File metadata and controls

29 lines (21 loc) · 1.17 KB

Browsersync

This helper enables you to see client-side changes in real-time using Browsersync. It works by spinning up a local server that watches files (according to the configuration) for changes to be able reload/inject static resources with or without reloading the page for every active browser session. Find more information in the official documentation.

Usage:

const cssFilesPath = '**/*.css';
const jsFilesPath = '**/*.js';

const browsersyncOptions = {    
    files: [
        cssFilesPath,
        jsFilesPath
    ]
}

gulp.task('browsersyncStart', () => browsersync.browsersyncServe(browsersyncOptions));

Using proxy mode requires an existing vhost added in the options, which Browsersync will create a proxy for.

If you are not using the proxy mode, the terminal will ask you to add a snippet just before the closing tag, for example:

<script id="__bs_script__">//<![CDATA[
    document.write("<script async src='http://HOST:3000/browser-sync/browser-sync-client.js'><\/script>".replace("HOST", location.hostname));
//]]></script>