Open WillyPoteloin opened 9 years ago
I try to manage the scripPath option for the browser sync client script with success with this code :
this.onServerSnippet = function browserSyncOnServerSnippet() {
// we look for sciptPath option
if(self.server.options.getIn(['scriptPath']) !== undefined) {
var scriptPath = self.server.options.getIn(['scriptPath']);
scriptPath = scriptPath('/browser-sync/browser-sync-client.VERSION.js').replace(/https?:\/\//,'');
}
else {
var scriptPath = 'location.hostname:PORT/browser-sync/browser-sync-client.VERSION.js';
}
var injectedJS = [
'(function(/* BrowserSync-Brunch */) {',
' var url = "//SCRIPTPATH";',
' var bs = document.createElement("script");',
' bs.type = "text/javascript"; bs.async = true; bs.src = url;',
' var s = document.getElementsByTagName("script")[0];',
' s.parentNode.insertBefore(bs, s);',
'})();'
]
.join("\n")
.replace(/SCRIPTPATH/g, scriptPath)
.replace(/PORT/g, self.server.options.getIn(['port']))
.replace(/VERSION/g, self.server.options.getIn(['version']));
params.data = injectedJS;
callback(null, params);
};
and this option in brunch config
plugins:
browserSync:
port: 81
scriptPath: (path) -> "http://twistin.fr:1281"+path;
Unfortunately when the browser sync client script is loaded it tries to load browser sync socket io on the port 81... This is weird because if i directly use the browser-sync CLI with this option the path is modify for every script and everything is working fine except that there is (i think) a conflict between the browser-sync chokidar instance and the brunch watch chokidar instance.
Hi ! I have a issue with the scriptPath option. It seems to be not apply.
plugins: browserSync: port: 81 scriptPath: "localhost:1281/browser-sync/browser-sync-client.2.1.6.js"
but when i reach localhost:80 it tries to get the browser-sync-client from localhost:81 which is ok according to port option but i need to retrieve the script from a other port because i'm on a virtual server address form the internet with port prefix '12' so when i want to reach port 81 form the internet i need to address the port 1281. I hope this is clear if it's not feel free to ask.
Thanks.