Easily use BrowserSync in your Webpack project.
Install:
$ npm install --save-dev browser-sync-webpack-plugin
Usage:
BrowserSync will start only when you run Webpack in watch mode:
$ webpack --watch
Basic:
In your webpack.config.js
:
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
module.exports = {
plugins: [
new BrowserSyncPlugin({
host: 'localhost',
port: 3000,
server: { baseDir: ['public'] }
})
]
}
Advanced:
In your webpack.config.js
:
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
module.exports = {
plugins: [
new BrowserSyncPlugin(
{
host: 'localhost',
port: 3000,
server: { baseDir: ['public'] }
},
{
name: 'my-awesome-bs-instance',
callback: function () {
console.log('browserSync started!');
},
reload: true
}
)
]
}
Contributing:
Feel free to open issues to propose stuff and participate. Pull requests are also welcome.
Licence:
MIT