11var _ = require ( 'lodash' ) ;
22var browserSync = require ( 'browser-sync' ) ;
33
4- function BrowserSyncPlugin ( browserSyncOptions , options ) {
4+ function BrowserSyncPlugin ( browserSyncOptions , pluginOptions ) {
55 var self = this ;
66
7- var defaultOptions = {
7+ var defaultPluginOptions = {
88 reload : true ,
99 name : 'bs-webpack-plugin' ,
1010 callback : undefined
1111 } ;
1212
1313 self . browserSyncOptions = _ . extend ( { } , browserSyncOptions ) ;
14- self . options = _ . extend ( { } , defaultOptions , options ) ;
14+ self . options = _ . extend ( { } , defaultPluginOptions , pluginOptions ) ;
1515
1616 self . browserSync = browserSync . create ( self . options . name ) ;
17- self . webpackIsWatching = false ;
18- self . browserSyncIsRunning = false ;
17+ self . isWebpackWatching = false ;
18+ self . isBrowserSyncRunning = false ;
1919}
2020
2121BrowserSyncPlugin . prototype . apply = function ( compiler ) {
2222 var self = this ;
2323
2424 compiler . plugin ( 'watch-run' , function ( watching , callback ) {
25- self . webpackIsWatching = true ;
25+ self . isWebpackWatching = true ;
2626 callback ( null , null ) ;
2727 } ) ;
2828
2929 compiler . plugin ( 'compilation' , function ( ) {
30- self . browserSync . notify ( 'Rebuilding' ) ;
30+ if ( self . isBrowserSyncRunning ) {
31+ self . browserSync . notify ( 'Rebuilding...' ) ;
32+ }
3133 } ) ;
3234
3335 compiler . plugin ( 'done' , function ( stats ) {
34- if ( self . webpackIsWatching ) {
35- if ( self . browserSyncIsRunning ) {
36+ if ( self . isWebpackWatching ) {
37+ if ( self . isBrowserSyncRunning ) {
3638 if ( self . options . reload ) {
3739 self . browserSync . reload ( ) ;
3840 }
@@ -43,7 +45,7 @@ BrowserSyncPlugin.prototype.apply = function (compiler) {
4345 self . browserSync . init ( self . browserSyncOptions ) ;
4446 }
4547
46- self . browserSyncIsRunning = true ;
48+ self . isBrowserSyncRunning = true ;
4749 }
4850 }
4951 } ) ;
0 commit comments