src/deliver.js
function(bs, event, filePath) {

	const fileName = path.parse(filePath).base
	const fileExtension = path.extname(filePath)

	// Ignore change when filePath is junk
	if (junk.is(fileName) === true) return

	// Flush the cache no matter what event was send by Chokidar.
	// This ensures that we serve the latest files when the user reloads the site.
	cache.flush(filePath)

	const styleExtensions = [
		'.css',
		'.scss',
		'.sass',
		'.less'
	]

	// Reload stylesheets when the file extension is a known style extension
	if (styleExtensions.includes(fileExtension) === true) return bs.reload('*.css')

	const imageExtensions = [
		'.png',
		'.jpg',
		'.jpeg',
		'.svg',
		'.gif',
		'.webp'
	]

	// Reload images when the file extension is a known image extension supported by Browsersync
	if (imageExtensions.includes(fileExtension) === true) return bs.reload(`*${ fileExtension }`)

	bs.reload()

}
function(bs, event, filePath) {

	const fileName = path.parse(filePath).base
	const fileExtension = path.extname(filePath)

	// Ignore change when filePath is junk
	if (junk.is(fileName) === true) return

	// Flush the cache no matter what event was send by Chokidar.
	// This ensures that we serve the latest files when the user reloads the site.
	cache.flush(filePath)

	const styleExtensions = [
		'.css',
		'.scss',
		'.sass',
		'.less'
	]

	// Reload stylesheets when the file extension is a known style extension
	if (styleExtensions.includes(fileExtension) === true) return bs.reload('*.css')

	const imageExtensions = [
		'.png',
		'.jpg',
		'.jpeg',
		'.svg',
		'.gif',
		'.webp'
	]

	// Reload images when the file extension is a known image extension supported by Browsersync
	if (imageExtensions.includes(fileExtension) === true) return bs.reload(`*${ fileExtension }`)

	bs.reload()

}
function ( bs , event , filePath ) { const fileName = path . parse ( filePath ) . base const fileExtension = path . extname ( filePath ) // Ignore change when filePath is junk if ( junk . is ( fileName ) === true ) return // Flush the cache no matter what event was send by Chokidar. // This ensures that we serve the latest files when the user reloads the site. cache . flush ( filePath ) const styleExtensions = [ '.css' , '.scss' , '.sass' , '.less' ] // Reload stylesheets when the file extension is a known style extension if ( styleExtensions . includes ( fileExtension ) === true ) return bs . reload ( '*.css' ) const imageExtensions = [ '.png' , '.jpg' , '.jpeg' , '.svg' , '.gif' , '.webp' ] // Reload images when the file extension is a known image extension supported by Browsersync if ( imageExtensions . includes ( fileExtension ) === true ) return bs . reload ( ` ${ fileExtension } ` ) bs . reload ( ) }
Flushes the cache and reloads the site.
Should be executed when a file gets updated.
@param {Object} bs - Browsersync instance.
@param {String} event - Event sent by Chokidar.
@param {String} filePath - File affected by event (relative).
@returns {?*}
Flushes the cache and reloads the site . Should be executed when a file gets updated .