How to use the browser-sync.create function in browser-sync

To help you get started, we’ve selected a few browser-sync examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Jacky-fe / react-isomorphic-skeleton / tools / start.js View on Github external
await new Promise((resolve, reject) =>
    browserSync.create().init(
      {
        // https://www.browsersync.io/docs/options
        server: 'src/server.js',
        middleware: [server],
        port: config.port,
        open: !process.argv.includes('--silent'),
        ...(DEBUG ? {} : { notify: false, ui: false }),
      },
      (error, bs) => (error ? reject(error) : resolve(bs)),
    ),
  );
github BastiTee / d3-workbench / bin / d3-wb-server.js View on Github external
#!/usr/bin/env node

'use strict';

const demosymbol = '+DEMO';

// external libraries
const express = require('express');
const server = express();
const fs = require('fs');
const path = require('path');
const parse = require('minimist');
const bs = require('browser-sync').create();
const internalPort = 61426;
const pj = require('../package.json');

const showHelp = function() {
    console.log('');
    console.log('Usage:');
    console.log('');
    console.log('    node d3-wb-server.js -i WORKBENCH [OPTIONS...]');
    console.log('    npm start -- -i WORKBENCH [OPTIONS...]');
    console.log('');
    console.log('    -i WORKBENCH    Path to your workbench folder.' +
        ' Use +DEMO for example content.');
    console.log('');
    console.log('Optional arguments:');
    console.log('');
    console.log('    -p PORT         Server port. Defaults to 50321.');
github gabrielflorit / blockup / src / serveBlock.js View on Github external
var fs = require('fs-extra')
var path = require('path')
var bs = require('browser-sync').create()
var buble = require('buble')
var chalk = require('chalk')
var UglifyJS = require('uglify-js')
var cheerio = require('cheerio')

module.exports = function() {

	console.log(chalk.green('Serving current block:'))

	// Watch index.html and reload.
	bs.watch(path.join(process.cwd(), 'index.html')).on('change', bs.reload)

	// Watch script.js, compile, uglify, inline, and reload.
	bs.watch(path.join(process.cwd(), 'script.js'), function (event, file) {
		if (event === 'change') {
github roots / sage / gulpfile.js View on Github external
// ## Globals
var argv         = require('minimist')(process.argv.slice(2));
var autoprefixer = require('gulp-autoprefixer');
var browserSync  = require('browser-sync').create();
var changed      = require('gulp-changed');
var concat       = require('gulp-concat');
var flatten      = require('gulp-flatten');
var gulp         = require('gulp');
var gulpif       = require('gulp-if');
var imagemin     = require('gulp-imagemin');
var eslint       = require('gulp-eslint');
var lazypipe     = require('lazypipe');
var less         = require('gulp-less');
var merge        = require('merge-stream');
var minifyCss    = require('gulp-minify-css');
var plumber      = require('gulp-plumber');
var rev          = require('gulp-rev');
var runSequence  = require('run-sequence');
var sass         = require('gulp-sass');
var sourcemaps   = require('gulp-sourcemaps');
github shakyShane / bs-rewrite-rules / tests / init.js View on Github external
function startWithRules (rules, cb) {
    browserSync.reset();
    var bs = browserSync.create();

    bs.init({
        server: "test/fixtures",
        logLevel: "silent",
        rewriteRules: rules,
        open: false,
        plugins: [{module: plugin}]
    }, cb);
}
github chrisathook / display-standard-previewer / gulp / index.js View on Github external
'use strict';
var gulp = require('gulp');
var config = require('./config');
var bs = require('browser-sync').create();
var util = require('gulp-util');
var path = require('path');
var checkTemplateType = function () {
  var fs = require("fs");
  var file = fs.readFileSync(path.join(process.cwd(), 'index.html'), 'utf8');
  //console.log (file);
  //console.log("String"+(file.search('')>-1 ? " " : " not ")+"found");
  if (file.search('') > -1) {
    config = config('img', 'dist', 'js');
  } else {
  
    let root = process.cwd();
    
  
    let imagePath = '';
    let jsPath = '';
github reptar / reptar / lib / cli / watch.js View on Github external
showSpinner: false,
    ...options,
  });

  await reptar.update();

  const server = new Server(reptar);
  await server.start();

  activity.end(startActivity);

  process.stdout.write('\n');
  log.info('Server running at:', server.server.info.uri);

  if (options.browserSync) {
    const browserSync = bsCreate();
    browserSync.init({
      files: `${reptar.config.get('path.source')}/**/*`,
      proxy: server.server.info.uri,
    });
  }
}
github kevinkhill / lavacharts / javascript / gulp-functions / Compile.js View on Github external
import args from 'yargs';
import gulpif from 'gulp-if';
import source from 'vinyl-source-stream';
import notifier from 'node-notifier';
import browserify from 'browserify';
import uglify from 'gulp-uglify';
import babelify from 'babelify';
import watchify from 'watchify';
import streamify from 'gulp-streamify';
import { dest } from 'gulp';
import { log } from 'gulp-util';
import { red, green } from 'chalk';
import { create as createBrowserSync } from 'browser-sync';

const browserSync = createBrowserSync();

let bundler = browserify({
    debug: true,
    entries: ['./src/lava.entry.js'],
    cache: {},
    packageCache: {},
    transform: [
        'browserify-versionify',
        ['babelify', {presets: ['es2015'] }]
    ]
});

function rebundle(prod = false) {
    return bundler.bundle()
        .on('error', err => {
            if (err instanceof SyntaxError) {
github Va1 / browser-sync-webpack-plugin / lib / BrowserSyncPlugin.js View on Github external
constructor (browserSyncOptions, pluginOptions) {
    this.browserSyncOptions = Object.assign({}, browserSyncOptions)
    this.options = Object.assign({}, defaultPluginOptions, pluginOptions)

    this.browserSync = browserSync.create(this.options.name)
    this.isWebpackWatching = false
    this.isBrowserSyncRunning = false
  }