gulp-browsersync-inject
Injects BrowserSync JavaScript into an HTML file; this is useful for proxy mode without directly modifying the HTML file..
Information
Package | gulp-browsersync-inject |
Description | Inject BrowserSync code into an HTML document. This is useful to support proxy mode without modifying the HTML document. |
Node Version | >= 0.9 |
Gulp Version | 3.x |
Usage
Install
$ npm install gulp-browsersync-inject --save-dev
Example
var gulp = ;var browserSyncInject = ; // Basic usage:gulp;
Options
options.port (REQUIRED)
The port to which is being proxied. This is the port which BrowserSync is listening on.
Type: `Number`
Example:
options.version
The version of the BrowserSync library. BrowserSync will output this value when launched.
Type: `String`
Default: `2.24.4`
Example:
options.protocol
The protocol to use (http or https). If not specified, the injected code will default to no protocol, causing the browser will use the served protocol.
Type: `String`
Default: ``
Example:
options.path
The path to the JavaScript file. Only specify the file without version or extension.
Type: `String`
Default: `/browser-sync/browser-sync-client`
Example:
// Puts the information into the 'head' DOM element
options.tag
Set a specific tag to insert before it.
Type: `String`
Default: `head`
Example:
// Puts the information into the 'head' DOM element
options.indent
Number of spaces for indentation (for formatting).
Type: `Number`
Default: `4`
Example:
options.template
The raw template to inject. All options are resolvers and will be resolved at injection time.
Type: `String`
Default:
'<script type=\'text/javascript\' id="__bs_script__">//<![CDATA[
document.write("<script async src=\'${PROTOCOL}//HOST:${PORT}${PATH}.${VERSION}.js\'><\\\/script>".replace("HOST", location.hostname));
'//]]></script>'
Example: