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

@theme-tools/plugin-browser-sync

v1.0.1

Published

Browser Sync plugin for Theme Core

Downloads

51

Readme

Browser Sync Plugin for Theme Tools

Theme core plugins let you easily pass in configuration and get a set of Gulp-ready task functions back that have sensible defaults and work well together.

Getting Started

Requirements

  • Gulp 4 installed with npm install --save gulp@4

Install

npm install @theme-tools/plugin-browser-sync --save

Configure

The config that is passed in is merged with config.default.js. We suggest starting with config.simple.js to get started:

cp node_modules/@theme-tools/plugin-browser-sync/config.simple.js config.browser-sync.js

Setup

Add this to your gulpfile.js:

const gulp = require('gulp');
const config = {};
config.browserSync = require('./config.browser-sync.js');
const browserSyncTasks = require('@theme-tools/plugin-browser-sync')(config.browserSync);

gulp.task('serve', browserSyncTasks.serve);

Details

Tasks

These tasks are methods inside browserSyncTasks from the above code example. You can run them anyway you can run a function, though they are often ran via Gulp. All tasks take a callback function as the first and only parameter that will run when the task is done - exactly how gulp.task(), gulp.parallel(), and gulp.series() want.

browserSyncTasks.serve() - Create server

Create server using Browser Sync.

browserSyncTasks.reload() - Reload the page

Probably not needed. Wraps .reload() so you can just fire it or pass in a string or array of strings of paths of files to reload which can allow CSS files to get injected.

Configuration

All configuration is deep merged with config.default.js.

baseDir

Type: Object | String | Boolean Default: ./

Where to serve static files from. Disabled when domain is set. Passed to browser-sync's server where lots of extra config info can be found.

domain

Type: String Default: null

If you have local hosting already going and you want to use BrowserSync's proxy, then set your local domain here (ie mysite.dev). Having this set disables the static server. Passed to browser-sync's proxy.

startPath

Type: String Default: ''

The path shown when the URLs are shown in the Terminal. If you have Pattern Lab going, it's nice to have pattern-lab/public set.

watchFiles

Type: Array<String> Default: []

Files to watch that will trigger a reload; css files will try to be injected (as long as they are brought using <link> and not <style>@import</style>). Passed to browser-sync's files.

openBrowserAtStart

Type: Boolean Default: false

If the browser(s) should open at the start.

browsers

Type: Array<String> Default: [ 'Google Chrome' ]

If openBrowserAtStart, then which browsers to open.

tunnel

Type: Boolean Default: false

Tunnel the Browsersync server through a random Public URL like -> http://randomstring23232.localtunnel.me. Great for showing to other people remotely or testing sites on Browser Stack. Passed to browser-sync's tunnel.

port

Type: Number Default: 3050

The port to use (i.e. http://localhost:3050). If the port is taken, it will increment by one and use that port so you can have multiple instances running if needed.

reloadDelay

Type: Number Default: 50

How long to wait, in milliseconds, between file change and reload.

reloadDebounce

Type: Number Default: 750

Wait for a specified window of event-silence before sending any reload events. Passed to browser-sync's reloadDebounce.

Theme Core Events

This is only info for other Theme Core plugin developers.

on 'reload'

When a 'reload' event is emmitted, Browser Sync fires the reload() method.

files

Type: String | Array<String> Default: []

Files to reload/inject.