@polylith/builder 0.2.18 → 0.2.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/App.js +34 -3
  2. package/package.json +1 -1
package/App.js CHANGED
@@ -204,6 +204,23 @@ export default class App {
204
204
  return './' + path;
205
205
  }
206
206
 
207
+ /**
208
+ * Call this method with to set specific options for live reload
209
+ *
210
+ * @param {Object} on set to true to turn on destination watching
211
+ * @property {Number} port set this to a port for as livereload port,
212
+ * defaults to 35800
213
+ * @property {("http"|"https")} protocol the protocol to use for the
214
+ * livereload websocket. default to 'http'
215
+ * @property hostname the hostname for the livereload websocket. defaults to
216
+ * 'localhost;
217
+ * @property {Object} https if this has a value, it will be set as the http
218
+ * value in the livereload options
219
+ */
220
+ setLiveReloadOptions(options) {
221
+ this.liveReloadOptions = options;
222
+ }
223
+
207
224
  /**
208
225
  * Call this method with true to reload the browser when any files in the
209
226
  * destination folder have changed.
@@ -717,9 +734,23 @@ export default class App {
717
734
  ];
718
735
 
719
736
  if (this.liveReload) {
720
- plugins.push(
721
- livereload(this.destPath)
722
- )
737
+ let plugin;
738
+
739
+ // rollup-plugin-livereload always bases the protocol on the
740
+ // webpage url. This is bad, here we override it
741
+ if (this.liveReloadOptions) {
742
+ let port = this.liveReloadOptions.port || 35800;
743
+ let protocol = this.liveReloadOptions.protocol || 'http';
744
+ let hostname = this.liveReloadOptions.hostname || 'localhost';
745
+ let https = this.liveReloadOptions.https || null;
746
+ let url = `${protocol}://${hostname}:${port}/livereload.js?snipver=1&port=${port}`;
747
+
748
+ plugin = livereload({watch: this.destPath, https: https, clientUrl: url, port: port})
749
+ } else {
750
+ plugin = livereload(this.destPath)
751
+ }
752
+
753
+ plugins.push(plugin)
723
754
  }
724
755
 
725
756
  var config = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polylith/builder",
3
- "version": "0.2.18",
3
+ "version": "0.2.20",
4
4
  "description": "The polylith builder",
5
5
  "main": "index.js",
6
6
  "type": "module",