How to use the create function from browser-sync
Find comprehensive JavaScript browser-sync.create code examples handpicked from public code repositorys.
browser-sync.create creates a new BrowserSync instance with the given options.
GitHub: kaisermann/selene
39 40 41 42 43 44 45 46 47 48
watchFiles: [], whitelist: [], blacklist: [], ...Manifest.browserSync, } Manifest.browserSyncInstance = browserSync.create() } module.exports = { getDirectoryName (resourceType) {
+ 3 other calls in file
10 11 12 13 14 15 16 17 18 19
module.exports = function (gulp, paths) { gulp.task('e2e', function (done) { let compress = require('compression'); let server = browserSync.create(); server.init({ open: false, notify: false,
+ 7 other calls in file
How does browser-sync.create work?
The browser-sync.create method creates a new instance of the BrowserSync server with customizable options, allowing you to control the behavior and configuration of the server. When invoked, it returns a new BrowserSync instance which can then be used to start the server and control its behavior.
32 33 34 35 36 37 38 39 40 41
next(); }; const middleware = [devMiddleware, hotMiddleware, addQueryParams]; this.app = browserSync.create(); this.app.init( { baseDir: compiler.outputPath,
GitHub: phamtri2395/redux-starter
26 27 28 29 30 31 32 33 34 35
// Clean leftover files rimraf.sync(webpackConfig.output.path, { nosort: true, dot: true }); rimraf.sync(html_path, { nosort: true, dot: true }); // Control Browsersync instances let bsCount = 0; const bs = browserSync.create(); // Start webpack dev server const compiler = webpack(webpackConfig); const webpackDevMiddleware = require('webpack-dev-middleware')(compiler, {
+ 7 other calls in file
Ai Example
1 2 3 4 5 6 7 8 9 10 11
const browserSync = require("browser-sync"); // Create a new instance of BrowserSync const bs = browserSync.create(); // Initialize the server bs.init({ server: "./public", port: 3000, open: false, });
In this example, browser-sync.create() is used to create a new instance of BrowserSync, which is then used to initialize a server with some options. The server option specifies the directory to serve files from, port specifies the port to listen on, and open is set to false to prevent the server from automatically opening a browser window.
GitHub: markserv/markserv-cli
5 6 7 8 9 10 11 12 13
const start = syncConfig => { log.trace('Initiating browserSync') log.trace(syncConfig) browserSync.init(syncConfig) serverInstance = browserSync.create() // serverInstance = browserSync.create('Server1') return serverInstance }
+ 3 other calls in file
37 38 39 40 41 42 43 44 45 46
```javascript var browserSync = require('browser-sync'); var bsSystemHotReloader = require('bs-systemjs-hot-reloader'); var bs = browserSync.create(); bs.watch([ 'index.html', 'jspm.config.js'
10 11 12 13 14 15 16 17 18 19
var postcss = require('postcss'); // Two instances of BrowserSync — one for Reddit, the other for the local server // for the stylesheet var browserSync = require('browser-sync'); var bs1 = browserSync.create('local'); var bs2 = browserSync.create('proxy'); gulp.task('setup-servers', function() { // Run the local server first
+ 15 other calls in file
110 111 112 113 114 115 116 117 118 119 120 121 122
runSequence('build-html', 'build-css', 'build-js', 'build-img', 'build-vendor', 'build-docs'); }) gulp.task('sync', ['locale-check', 'build-html', 'build-css', 'build-js', 'build-img', 'build-vendor', 'build-docs'], function() { var enBrowser = browserSync.create(); enBrowser.init({ server: { baseDir: "build/" + localization
+ 13 other calls in file
15 16 17 18 19 20 21 22 23 24 25 26 27
const user = require('../main.config.js') const sh = require('kool-shell/namespaced')('__kirbywebpack') const LOGPATH = path.join(process.cwd(), 'php-error.log') const bs = browserSync.create() const useProxy = !!user.devServer.proxy let isWebpackInit, isPhpInit let compiler
8 9 10 11 12 13 14 15 16 17
const bs = require('browser-sync'); const { argv } = require('yargs'); // Browser sync server async function server() { let browserSync = bs.create(); let { config } = configUtil.getConfig(); // Proxy the dev version of news-platform. (assumes the host file has been set up) // https://github.com/MinneapolisStarTribune/news-platform
49 50 51 52 53 54 55 56 57 58
// Get 404 info page const content_404 = fs.readFileSync(path.join(__dirname, '404.html')); // Initialize Browsersync and webpack const sync = browser_sync.create(); const get_filter = file => { const file_relative = path.relative(__dirname, file); debug(`File relative: ${file_relative}`);
18 19 20 21 22 23 24 25 26 27
gulp.task('browser-sync', () => { Object.keys(servers).forEach((serverName) => { browserSync.create(serverName); const proxies = servers[serverName].proxies.map((p) => { return proxy(
+ 7 other calls in file
browser-sync.init is the most popular function in browser-sync (523 examples)