Skip to content

Commit 7311115

Browse files
author
Valentyn
committed
addition to the noderat's pull request. minor naming improvements. lodash dependency update. version 1.1.0
1 parent 7a41c7b commit 7311115

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

index.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
var _ = require('lodash');
22
var 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

2121
BrowserSyncPlugin.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
});

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "browser-sync-webpack-plugin",
3-
"version": "1.0.3",
3+
"version": "1.1.0",
44
"description": "BrowserSync and Webpack integration",
55
"keywords": [
66
"webpack",
@@ -12,7 +12,7 @@
1212
],
1313
"main": "index.js",
1414
"dependencies": {
15-
"lodash": "^3.x.x"
15+
"lodash": "^4.x.x"
1616
},
1717
"devDependencies": {},
1818
"peerDependencies": {

0 commit comments

Comments
 (0)