kopia lustrzana https://github.com/shoelace-style/shoelace
dev: start BrowserSync timeout after server init
rodzic
dbb4be7cfa
commit
2f46b6f507
|
@ -99,8 +99,7 @@ fs.mkdirSync(outdir, { recursive: true });
|
||||||
// Make sure docs/dist is empty since we're serving it virtually
|
// Make sure docs/dist is empty since we're serving it virtually
|
||||||
del.sync('docs/dist');
|
del.sync('docs/dist');
|
||||||
|
|
||||||
// Launch browser sync
|
const browserSyncConfig = {
|
||||||
bs.init({
|
|
||||||
open: false,
|
open: false,
|
||||||
startPath: '/',
|
startPath: '/',
|
||||||
port,
|
port,
|
||||||
|
@ -116,26 +115,33 @@ fs.mkdirSync(outdir, { recursive: true });
|
||||||
'/dist': './dist'
|
'/dist': './dist'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Configure socketIO to retry forever when disconnected to enable the auto-reattach timeout below to work
|
|
||||||
socket: {
|
socket: {
|
||||||
socketIoClientConfig: {
|
socketIoClientConfig: {
|
||||||
|
// Configure socketIO to retry forever when disconnected to enable the auto-reattach timeout below to work
|
||||||
reconnectionAttempts: Infinity,
|
reconnectionAttempts: Infinity,
|
||||||
reconnectionDelay: 500,
|
reconnectionDelay: 500,
|
||||||
reconnectionDelayMax: 500,
|
reconnectionDelayMax: 500,
|
||||||
timeout: 1000
|
timeout: 1000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
setTimeout(() => {
|
// Launch browser sync
|
||||||
const url = `http://localhost:${port}`;
|
bs.init(browserSyncConfig, () => {
|
||||||
console.log(chalk.cyan(`Launched the Shoelace dev server at ${url} 🥾\n`));
|
// This init callback gets executed after the server has started
|
||||||
if (Object.keys(bs.sockets.sockets).length === 0) {
|
const socketIoConfig = browserSyncConfig.socket.socketIoClientConfig;
|
||||||
open(url);
|
// Wait enough time for any open, detached clients to have a chance to reconnect. This will be used to determine if we reload an existing tab or open a new one.
|
||||||
} else {
|
const tabReattachDelay = socketIoConfig.reconnectionDelayMax * 2 + socketIoConfig.timeout;
|
||||||
bs.reload();
|
setTimeout(() => {
|
||||||
}
|
const url = `http://localhost:${port}`;
|
||||||
}, 2000);
|
console.log(chalk.cyan(`Launched the Shoelace dev server at ${url} 🥾\n`));
|
||||||
|
if (Object.keys(bs.sockets.sockets).length === 0) {
|
||||||
|
open(url);
|
||||||
|
} else {
|
||||||
|
bs.reload();
|
||||||
|
}
|
||||||
|
}, tabReattachDelay);
|
||||||
|
});
|
||||||
|
|
||||||
// Rebuild and reload when source files change
|
// Rebuild and reload when source files change
|
||||||
bs.watch(['src/**/!(*.test).*']).on('change', async filename => {
|
bs.watch(['src/**/!(*.test).*']).on('change', async filename => {
|
||||||
|
|
Ładowanie…
Reference in New Issue