Adds automatic browser reloading support to
brunch when using the brunch watch
command.
The plugin uses BrowserSync technology to keep multiple browsers & devices in sync when building websites.
##Features from BrowserSync
- Scroll - I can keep your pages in sync when scrolling.
- Forms - You fill out a form in one browser, I'll copy the data to all the others.
- Links - I'll watch your clicks and make all the other browsers follow you.
- CSS injecting - I can even watch your CSS files & inject them when they change.
- Live Reload - I can also watch files like HTML and PHP & when they change I can reload all browsers for you.
- Built-in Server - Yep, I can serve static files too if you need me to (uses Connect).
- Use with any back-end setup - I even have a proxy option so that I can be used with existing PHP, Rails, Python, Node or ASP.net setup.
- Public URL - View your website via a URL that any internet connected device can access & maintain all BrowserSync features.
- Browser Stack support - Use the all of my features when viewing your site through Browser Stack.
Make sure that you have removed auto-reload brunch from your package.json if you were using it.
Install the plugin via npm with npm install --save browser-sync-brunch
.
Or, do manual install:
- Add
"browser-sync-brunch": "x.y.z"
topackage.json
of your brunch app. - If you want to use git version of plugin, add
"browser-sync-brunch": "git+ssh://git@github.com:ocombe/browser-sync-brunch.git"
.
In most cases, browser-sync-brunch works out of the box without any further configuration. Stylesheet and image changes will be applied seamlessly, and any other changes will trigger a page refresh.
Because of a disputable assumption in BrowserSync’s code (we’re working with them to fix this), any --server
in your CLI (e.g. brunch watch --server
) will be incorrectly interpreted by BrowserSync as asking it to run its own server, which in turn will result in an incorrect Socket.IO binding. Besides preventing your pages from using BrowserSync, it will start a fast loop of reconnections with Socket.IO, which will quickly consume a lot of CPU.
If you wish to run Brunch's built-in server on watch, either use its configuration file instead of the CLI option:
server:
run: true
…or use the CLI option shorthand, -s
, instead of --server
.
If customization is needed or desired, settings can be modified in your brunch config file (such as brunch-config.coffee
).
You can use any BrowserSync option, refer to their documentation for the complete list.
Example:
exports.config: {
...
plugins: {
browserSync: {
port: 3333,
logLevel: "debug"
}
}
}
Be careful, this plugin won't work with Brunch workers enabled because of an error in Brunch source code.*