How to use the browser-sync.emitter 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 flovan / headstart / gulpfile.js View on Github external
gulp.task('browsersync', function (cb) {
	
	verbose(chalk.grey('Running task "browsersync"'));
	console.log(chalk.grey('Launching server...'));

	// Grab the event emitter and add some listeners
	var evt = browserSync.emitter;
	evt.on('init', bsInitHandler);
	evt.on('service:running', bsRunningHandler);

	// Serve files and connect browsers
	browserSync.init(null, {
		server:         _.isUndefined(config.proxy) ? {
							baseDir: config.export_templates
						} : false,
		logConnections: false,
		logLevel:       'silent', // 'debug'
		browser:        config.browser || 'default',
		open:           isOpen,
		port:           config.port || 3000,
		proxy:          config.proxy || false,
		tunnel:         isTunnel || null
	}, function (err, data) {
github wikipathways / pvjs / gulp / tasks / browser-sync.js View on Github external
// see setup guide for using with gulp: http://www.browsersync.io/docs/gulp/
var browserSync = require('browser-sync');
var evt = browserSync.emitter;
var gulp        = require('gulp');
var packageJson = require('../../package.json');
var reload      = browserSync.reload;

evt.on('rs', function() {
  console.log('You want to reload BrowserSync!');
});

/*
gulp.task('browser-sync', ['browserify', 'browserify-polyfills'], function() {
  browserSync(['./index.js', './lib/polyfills.js'], {
  //*/
gulp.task('browser-sync', ['browserify'], function() {
  browserSync({
		server: {
			baseDir: './'
github google / ioweb2015 / gulp_scripts / backend.js View on Github external
var serverAddr = 'localhost:' + port;
  var url = 'http://' + serverAddr + IOWA.urlPrefix;
  var args = [
    'preview', 'app', 'run', opts.dir,
    '--host', serverAddr,
    '--datastore-path', IOWA.backendDir + '/.gae_datastore'
  ];

  var backend = spawn('gcloud', args, {stdio: 'inherit'});
  if (!opts.reload) {
    console.log('The app should now be available at: ' + url);
    backend.on('close', callback);
    return url;
  }

  browserSync.emitter.on('service:exit', callback);
  // give GAE server some time to start
  setTimeout(browserSync.bind(null, {notify: false, open: false, port: 3000, proxy: serverAddr}), 2000);
  return 'http://localhost:3000' + IOWA.urlPrefix;
}