Readded page open and added auto-refresh

Added npm modules 'open-cli', 'concurrently', 'reload', and 'wait-cli'
NPM script 'hot' will now open the page once the server is up the first time thanks to 'wait-cli' and 'open-cli'
After that, 'reload' will take care of refresing the page when it's dead-man switch triggers

Co-authored-by: ndoker <pawelbarszcz@gmail.com>
This commit is contained in:
Julian Webb 2021-04-25 13:03:55 -07:00
parent 8fbe48e1b1
commit 2771508561
4 changed files with 1861 additions and 16 deletions

1849
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,11 +7,16 @@
"build": "node ./build.js ./build",
"serve": "node ./server.js ./build 3000",
"test": "npm run build && npm run serve",
"hot": "nodemon --exec npm test"
"hot": "concurrently \"nodemon --exec npm test\" \"await tcp localhost:3000 && open-cli http://localhost:3000\""
},
"author": "Lospec",
"license": "ISC",
"nodemonConfig": {
"ext": "js,hbs,scss",
"ignore": "build/"
},
"dependencies": {
"concurrently": "^6.0.2",
"express": "^4.16.4",
"fs-extra": "^7.0.1",
"gulp": "^4.0.2",
@ -21,6 +26,12 @@
"gulp-sass": "^4.0.2",
"handlebars-helper-svg": "git+https://bitbucket.org/skeddles/npm-handlebars-helper-svg-lospec-open-source.git",
"nodemon": "^2.0.7",
"open": "^8.0.6",
"open-cli": "^6.0.1",
"sass": "^1.17.3"
},
"devDependencies": {
"reload": "^3.1.1",
"wait-cli": "^1.0.0"
}
}

View File

@ -1,6 +1,6 @@
const path = require('path');
const express = require('express');
const reload = require('reload');
const app = express();
const BUILDDIR = process.argv[2] || './build';
@ -14,7 +14,7 @@ app.get('/', (req, res) => {
} else {
setTimeout(()=>{
console.log('closing server');
server.close();
res.app.server.close();
process.exit();
},1000*10);
}
@ -24,9 +24,9 @@ app.get('/', (req, res) => {
//ROUTE - other files
app.use(express.static(path.join(__dirname, BUILDDIR)));
//start server
var server = app.listen(PORT, () => {
console.log(`\nTemp server started at http://localhost:${PORT}!`);
//console.log('press ctrl+c to stop ');
reload(app).then(() => {
//start server
app.server = app.listen(PORT, function () {
console.log('Web server listening on port ' + PORT)
})
});

View File

@ -481,5 +481,6 @@
</script>
<script src="/pixel-editor/pixel-editor.js"></script>
<script src="/reload/reload.js"></script>
</body>
</html>