npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gulp-browsersync-inject

v1.0.1

Published

Inject BrowserSync code into an HTML document

Downloads

31

Readme

gulp-browsersync-inject

Injects BrowserSync JavaScript into an HTML file; this is useful for proxy mode without directly modifying the HTML file..

Build Status NPM version Dependency Status

Information

Usage

Install

$ npm install gulp-browsersync-inject --save-dev

Example

var gulp = require('gulp');
var browserSyncInject = require('gulp-browsersync-inject');

// Basic usage:
gulp.task('injectBrowserSync', function(){
  gulp.src('./index.html')
  .pipe(browserSyncInject({port: 5000})) // BrowserSync will output the proxy port
  .pipe(gulp.dest('./'));
});

Options

options.port (REQUIRED)

The port to which is being proxied. This is the port which BrowserSync is listening on.

Type: `Number`

Example:

.pipe(browserSyncInject({port: 5000}))

options.version

The version of the BrowserSync library. BrowserSync will output this value when launched.

Type: `String`
Default: `2.24.4`

Example:

.pipe(browserSyncInject({version: true}))

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:

.pipe(browserSyncInject({protocol: 'http', port: 5000}))

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:

.pipe(browserSyncInject({path: '/browser-sync/custom-browser-sync-client', port: 5000})) // Puts the information into the 'head' DOM element

options.tag

Set a specific tag to insert before it.

Type: `String`
Default: `head`

Example:

.pipe(browserSyncInject({tag: 'head', port: 5000})) // Puts the information into the 'head' DOM element

options.indent

Number of spaces for indentation (for formatting).

Type: `Number`
Default: `4`

Example:

.pipe(browserSyncInject({indent: 2, port: 5000}))

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:

.pipe(browserSyncInject({template: customTemplateString, port: 5000}))

LICENSE

MIT License