Easily use BrowserSync in your Webpack project.
$ npm install --save-dev browser-sync-webpack-plugin
BrowserSync will start only when you run Webpack in watch mode:
$ webpack --watch
If you're not using Webpack Dev Server, you can make BrowserSync to serve your project. The setup is pretty easy: just pass the BrowserSync options to the plugin as the first argument.
var BrowserSyncPlugin = ;moduleexports =// ...plugins:// browse to during development,// ./public directory is being servedhost: 'localhost'port: 3000server: baseDir: 'public'
The advanced usage is about using Webpack Dev Server with BrowserSync in order to use awesome features of both.
To achieve this, BrowserSync offers the proxy option. So, basically, you are about to proxy the output from the Webpack Dev Server through BrowserSync to get the best out of both.
var BrowserSyncPlugin = ;moduleexports =// ...plugins:// BrowserSync options// browse to during developmenthost: 'localhost'port: 3000// proxy the Webpack Dev Server endpoint// (which should be serving on )// through BrowserSyncproxy: ''// plugin options// prevent BrowserSync from reloading the page// and let Webpack Dev Server take care of thisreload: false
Feel free to open issues to propose stuff and participate. Pull requests are also welcome.