This commit is contained in:
chrosey
2017-09-13 07:52:34 +02:00
parent a1f16c37f4
commit 2340b0226b
24621 changed files with 2912161 additions and 149 deletions
+13
View File
@@ -0,0 +1,13 @@
# http://EditorConfig.org
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
[*.{js,json,md}]
indent_size = 2
+5
View File
@@ -0,0 +1,5 @@
.idea/
.DS_Store
*.log
*.swp
node_modules/
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Valentyn Barmashyn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+89
View File
@@ -0,0 +1,89 @@
# [BrowserSync](http://www.browsersync.io/) plugin for [Webpack](http://webpack.github.io/)
Easily use BrowserSync in your Webpack project.
## Install:
```bash
$ npm install --save-dev browser-sync-webpack-plugin
```
## Usage:
BrowserSync will start only when you run Webpack in [watch mode](http://webpack.github.io/docs/tutorials/getting-started/#watch-mode):
```bash
$ webpack --watch
```
### Basic:
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](http://www.browsersync.io/docs/options/) to the plugin as the first argument.
In your `webpack.config.js`:
```javascript
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
module.exports = {
// ...
plugins: [
new BrowserSyncPlugin({
// browse to http://localhost:3000/ during development,
// ./public directory is being served
host: 'localhost',
port: 3000,
server: { baseDir: ['public'] }
})
]
}
```
### Advanced:
The advanced usage is about using [Webpack Dev Server](https://github.com/webpack/webpack-dev-server) with BrowserSync in order to use awesome features of both.
To achieve this, BrowserSync offers the [proxy](http://www.browsersync.io/docs/options/#option-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.
In your `webpack.config.js`:
```javascript
var BrowserSyncPlugin = require('browser-sync-webpack-plugin');
module.exports = {
// ...
plugins: [
new BrowserSyncPlugin(
// BrowserSync options
{
// browse to http://localhost:3000/ during development
host: 'localhost',
port: 3000,
// proxy the Webpack Dev Server endpoint
// (which should be serving on http://localhost:3100/)
// through BrowserSync
proxy: 'http://localhost:3100/'
},
// plugin options
{
// prevent BrowserSync from reloading the page
// and let Webpack Dev Server take care of this
reload: false
}
)
]
}
```
Another plugin options supported are `name` - BrowserSync [instance name](http://www.browsersync.io/docs/api/#api-name)
and `callback` - BrowserSync [instance init callback](http://www.browsersync.io/docs/api/#api-cb).
## Contributing:
Feel free to open issues to propose stuff and participate. Pull requests are also welcome.
## Licence:
[MIT](http://en.wikipedia.org/wiki/MIT_License)
+54
View File
@@ -0,0 +1,54 @@
var _ = require('lodash');
var browserSync = require('browser-sync');
function BrowserSyncPlugin(browserSyncOptions, pluginOptions) {
var self = this;
var defaultPluginOptions = {
reload: true,
name: 'bs-webpack-plugin',
callback: undefined
};
self.browserSyncOptions = _.extend({}, browserSyncOptions);
self.options = _.extend({}, defaultPluginOptions, pluginOptions);
self.browserSync = browserSync.create(self.options.name);
self.isWebpackWatching = false;
self.isBrowserSyncRunning = false;
}
BrowserSyncPlugin.prototype.apply = function (compiler) {
var self = this;
compiler.plugin('watch-run', function (watching, callback) {
self.isWebpackWatching = true;
callback(null, null);
});
compiler.plugin('compilation', function () {
if (self.isBrowserSyncRunning) {
self.browserSync.notify('Rebuilding...');
}
});
compiler.plugin('done', function (stats) {
if (self.isWebpackWatching) {
if (self.isBrowserSyncRunning) {
if (self.options.reload) {
self.browserSync.reload();
}
} else {
if (_.isFunction(self.options.callback)) {
self.browserSync.init(self.browserSyncOptions, self.options.callback);
} else {
self.browserSync.init(self.browserSyncOptions);
}
self.isBrowserSyncRunning = true;
}
}
});
};
module.exports = BrowserSyncPlugin;
+97
View File
@@ -0,0 +1,97 @@
{
"_args": [
[
{
"raw": "browser-sync-webpack-plugin@^1.1.4",
"scope": null,
"escapedName": "browser-sync-webpack-plugin",
"name": "browser-sync-webpack-plugin",
"rawSpec": "^1.1.4",
"spec": ">=1.1.4 <2.0.0",
"type": "range"
},
"c:\\xampp\\htdocs\\laravel\\node_modules\\laravel-mix"
]
],
"_from": "browser-sync-webpack-plugin@>=1.1.4 <2.0.0",
"_id": "browser-sync-webpack-plugin@1.1.4",
"_inCache": true,
"_location": "/browser-sync-webpack-plugin",
"_nodeVersion": "7.4.0",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/browser-sync-webpack-plugin-1.1.4.tgz_1485792601597_0.8925799373537302"
},
"_npmUser": {
"name": "val_",
"email": "valrpeacher@gmail.com"
},
"_npmVersion": "4.0.5",
"_phantomChildren": {},
"_requested": {
"raw": "browser-sync-webpack-plugin@^1.1.4",
"scope": null,
"escapedName": "browser-sync-webpack-plugin",
"name": "browser-sync-webpack-plugin",
"rawSpec": "^1.1.4",
"spec": ">=1.1.4 <2.0.0",
"type": "range"
},
"_requiredBy": [
"/laravel-mix"
],
"_resolved": "https://registry.npmjs.org/browser-sync-webpack-plugin/-/browser-sync-webpack-plugin-1.1.4.tgz",
"_shasum": "ad3c0f7a3bd2d3e7f87cdc378ee93e7be2026d89",
"_shrinkwrap": null,
"_spec": "browser-sync-webpack-plugin@^1.1.4",
"_where": "c:\\xampp\\htdocs\\laravel\\node_modules\\laravel-mix",
"author": {
"name": "Valentyn Barmashyn",
"email": "valpreacher@gmail.com"
},
"bugs": {
"url": "https://github.com/Va1/browser-sync-webpack-plugin/issues"
},
"dependencies": {
"lodash": "4.x.x"
},
"description": "BrowserSync and Webpack integration",
"devDependencies": {},
"directories": {},
"dist": {
"shasum": "ad3c0f7a3bd2d3e7f87cdc378ee93e7be2026d89",
"tarball": "https://registry.npmjs.org/browser-sync-webpack-plugin/-/browser-sync-webpack-plugin-1.1.4.tgz"
},
"gitHead": "76c94fca1366dd1b33add6295edc6e6c9b01dcfd",
"homepage": "https://github.com/Va1/browser-sync-webpack-plugin",
"keywords": [
"webpack",
"webpack-plugin",
"browsersync",
"browser-sync",
"livereload",
"serve"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "val_",
"email": "valrpeacher@gmail.com"
}
],
"name": "browser-sync-webpack-plugin",
"optionalDependencies": {},
"peerDependencies": {
"browser-sync": "^2",
"webpack": "^1 || ^2 || ^2.0.0-beta || ^2.1.0-beta || ^2.2.0-rc.0"
},
"private": false,
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/Va1/browser-sync-webpack-plugin.git"
},
"scripts": {},
"version": "1.1.4"
}