mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
fix: livereload not working on second try (#1103)
* Fix livereload on second try * fix lint * Rename to LIVERELOAD_PORT
This commit is contained in:
parent
7aba299a3b
commit
49af2075b5
1 changed files with 5 additions and 5 deletions
|
@ -9,10 +9,9 @@ const gaze = require('gaze');
|
|||
const tinylr = require('tiny-lr');
|
||||
const readMetadata = require('./readMetadata.js');
|
||||
|
||||
let reloadScriptUrl;
|
||||
|
||||
function start(port) {
|
||||
process.env.NODE_ENV = 'development';
|
||||
process.env.LIVERELOAD_PORT = port;
|
||||
const server = tinylr();
|
||||
server.listen(port, () => {
|
||||
console.log('LiveReload server started on port %d', port);
|
||||
|
@ -26,11 +25,12 @@ function start(port) {
|
|||
});
|
||||
},
|
||||
);
|
||||
|
||||
reloadScriptUrl = `http://localhost:${port}/livereload.js`;
|
||||
}
|
||||
|
||||
const getReloadScriptUrl = () => reloadScriptUrl;
|
||||
const getReloadScriptUrl = () => {
|
||||
const port = process.env.LIVERELOAD_PORT;
|
||||
return `http://localhost:${port}/livereload.js`;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
start,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue