Webpack plugin that integrates BrowserSync for live reloading and cross-device testing during development. Current stable version is 2.4.0, with support for Webpack 1–5 and BrowserSync 2–3. It is typically used when you want BrowserSync's UI and synchronized browsing alongside Webpack's watch mode, either serving directly or proxying Webpack Dev Server. The plugin requires Node >=4 and is published on npm. Key differentiator: it adds BrowserSync's multi-device sync, UI dashboard, and tunnel capabilities to Webpack builds without needing to run a separate process. Contributions welcome, MIT license.
npm install browser-sync-webpack-pluginVerified import paths — ran on the pinned version, not inferred.
Shows basic usage of BrowserSyncPlugin with Webpack watch mode; starts a local server serving 'dist' directory on port 3000.
Set `injectCss: true` in plugin options to enable CSS injection without reload.
Use Node >=4. For older Node, use version 1.2.0.
Ensure you run webpack with --watch flag.
Pass `{ reload: false }` as second argument to BrowserSyncPlugin constructor.Install `browser-sync` as a devDependency with version 2.x or 3.x.
Run npm install --save-dev browser-sync
Use const BrowserSyncPlugin = require('browser-sync-webpack-plugin') or import BrowserSyncPlugin from 'browser-sync-webpack-plugin'Remove webpack.optimize.OccurrenceOrderPlugin and use default optimization in webpack.config.js.
Ensure you are not accidentally running browser-sync on server-side without proper configuration.