1 | ## auto-reload-brunch
|
2 | Adds automatic browser reloading support to
|
3 | [brunch](http://brunch.io) when using the `brunch watch` command.
|
4 |
|
5 | The plugin uses WebSocket technology to pass `compile` events to browser.
|
6 |
|
7 | ## Installation
|
8 | Install the plugin via npm with `npm install --save auto-reload-brunch`.
|
9 |
|
10 | Or, do manual install:
|
11 |
|
12 | * Add `"auto-reload-brunch": "x.y.z"` to `package.json` of your brunch app.
|
13 | Pick a plugin version that corresponds to your minor (y) brunch version.
|
14 | * If you want to use git version of plugin, add
|
15 | `"auto-reload-brunch": "git+ssh://git@github.com:brunch/auto-reload-brunch.git"`.
|
16 |
|
17 | ## Usage
|
18 | In most cases, auto-reload-brunch works out of the box without any further
|
19 | configuration. Stylesheet changes will be applied seamlessly, and any other
|
20 | changes will trigger a page refresh. To prevent a stylesheet from being reloaded
|
21 | automatically, set the ```data-autoreload="false"``` attribute on the stylesheet's
|
22 | link tag.
|
23 |
|
24 | ### Brunch plugin settings
|
25 | If customization is needed or desired, settings can be modified in your brunch
|
26 | config file (such as `brunch-config.coffee`):
|
27 |
|
28 | * __enabled__: _(Boolean or Object)_ Defaults to `true`
|
29 | * As a boolean, turn on Auto-Reloading for any change in your project, or
|
30 | off entirely.
|
31 | * As an object, enable Auto-Reloading for specific types of changes. Keys
|
32 | are the file extensions of compiled files (`js` or `css`) or `assets` to
|
33 | cover any other watched files that do not get compiled. When an object is
|
34 | used, only the types explicitly set to `true` will trigger an Auto-Reload.
|
35 | * __port__: _(Integer or Array of Integers)_ Defaults to `[9485..9495]`
|
36 | * The port to run the WebSocket server on. It will be applied automatically
|
37 | on the server and the client.
|
38 | * If an array, it will use the first value, but automatically fail over to
|
39 | the next value in the array if the attempted port is already in use on the
|
40 | system. This allows multiple instances to run without conflict.
|
41 | * __delay__: _(Integer, in milliseconds)_ Optional, no default
|
42 | * If your system is having race-condition type problems when the browser
|
43 | tries to reload immediately after a compile, use this to set a delay
|
44 | before the reload signal is sent.
|
45 | * __host__: (Default: '0.0.0.0') Server's host address.
|
46 | * __forceRepaint__: (Default: false) forcefully repaint the page after stylesheets
|
47 | refresh. Enabled in Chrome by default to mitigate the issue when it doesn't
|
48 | always update styles.
|
49 | * __keyPath__: Optional, no default.
|
50 | * Path to private key used for SSL.
|
51 | * __certPath__: Optional, no default.
|
52 | * Path to public x509 certificate.
|
53 |
|
54 | **Example:**
|
55 | ```coffeescript
|
56 | exports.config =
|
57 | ...
|
58 | # Every setting is optional.
|
59 | plugins:
|
60 | autoReload:
|
61 | enabled:
|
62 | css: on
|
63 | js: on
|
64 | assets: off
|
65 | port: [1234, 2345, 3456]
|
66 | delay: 200 if require('os').platform() is 'win32'
|
67 | keyPath: 'path/to/ssl.key'
|
68 | certPath: 'path/to/ssl.crt'
|
69 | ```
|
70 |
|
71 | ### Client-side settings
|
72 | If your `brunch watch` is running on a different machine than your
|
73 | preview screen, you can set `server` config variable to connect to a
|
74 | brunch/websocket server running at another ip address.
|
75 |
|
76 | ```html
|
77 | <script>
|
78 | window.brunch = window.brunch || {};
|
79 | window.brunch.server = '192.168.1.2';
|
80 | </script>
|
81 | ```
|
82 |
|
83 | You can also set the port (single integer only) and/or disable auto-reload
|
84 | via client-side scripting, although generally it's a better idea to use
|
85 | brunch config for this:
|
86 |
|
87 | ```javascript
|
88 | window.brunch['auto-reload'].port = 1234
|
89 | window.brunch['auto-reload'].disabled = true;
|
90 | ```
|
91 |
|
92 | ## License
|
93 |
|
94 | The MIT License (MIT)
|
95 |
|
96 | Copyright (c) 2012-2013 Paul Miller (http://paulmillr.com)
|
97 |
|
98 | Permission is hereby granted, free of charge, to any person obtaining a copy
|
99 | of this software and associated documentation files (the "Software"), to deal
|
100 | in the Software without restriction, including without limitation the rights
|
101 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
102 | copies of the Software, and to permit persons to whom the Software is
|
103 | furnished to do so, subject to the following conditions:
|
104 |
|
105 | The above copyright notice and this permission notice shall be included in
|
106 | all copies or substantial portions of the Software.
|
107 |
|
108 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
109 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
110 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
111 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
112 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
113 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
114 | THE SOFTWARE.
|