Skip to content

Commit

Permalink
remove HOT_RELOAD path from server code
Browse files Browse the repository at this point in the history
  • Loading branch information
sdumetz committed Jan 9, 2025
1 parent 5fc01d5 commit 909dd1b
Show file tree
Hide file tree
Showing 7 changed files with 1,809 additions and 10,254 deletions.
2,958 changes: 751 additions & 2,207 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 14 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,25 @@
"test": "cd source/server/ && npm test",
"build-ui": "cd source/ui && webpack --mode=production",
"build-server": "tsc -b source/server",
"watch": "cd source/server && HOT_RELOAD=1 NODE_ENV=development EXPERIMENTAL=1 ROOT_DIR=\"../../\" nodemon -e ts,js -w . -w ../ui/webpack.config.js -x ts-node index.ts"
"watch-server": "tsc -b source/server --watch",
"watch-ui": "cd source/ui && webpack --watch --mode=development",
"watch": "NODE_ENV=development concurrently -k --names \"ts,ui,eC\" \"npm run watch-server -- --preserveWatchOutput\" \"npm run watch-ui\" \"nodemon npm start\""
},
"author": "Holusion <[email protected]>",
"license": "Apache-2.0",
"engines": {
"node": ">=16.20.2"
"node": ">=16.20.2"
},
"devDependencies": {
"ts-node": "^10.9.2",
"typescript": "^4.9.4",
"webpack": "^5.88.1",
"webpack-cli": "^4.9.2"
"concurrently": "^9.1.2",
"nodemon": "^3.1.9",
"typescript": "^4.9.4"
},
"nodemonConfig": {
"delay": 100,
"extensions":["ts", "js"],
"watch": [
"source/server/dist"
]
}
}
18 changes: 2 additions & 16 deletions source/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,9 @@ export default async function createServer(config = defaultConfig) :Promise<expr
app.use("/dist", express.static(config.assets_dir));
}

/* istanbul ignore next */
if(config.hot_reload){
console.log("Hot reload enabled");
const {default: webpack} = await import("webpack");
const {default: middleware} = await import("webpack-dev-middleware");
//@ts-ignore
const {default: configGenerator} = await import("../../ui/webpack.config.js");

const compiler = webpack(configGenerator());
const webpackInstance = middleware(compiler as any, {});
app.use("/dist", webpackInstance);
await new Promise(resolve=> webpackInstance.waitUntilValid(resolve));
}else{
// static file server
app.use("/dist", express.static(config.dist_dir));
// static file server
app.use("/dist", express.static(config.dist_dir));

}


//Privilege-protected routes
Expand Down
2 changes: 1 addition & 1 deletion source/server/tests-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ global.createIntegrationContext = async function(c :Mocha.Context, config_overri
c.dir = await fs.mkdtemp(path.join(tmpdir(), titleSlug));
c.config = Object.assign(
parse({ //Common options
ROOT_DIR: c.dir, CLEAN_DATABASE: "false", VERBOSE: "false", HOT_RELOAD: "false",
ROOT_DIR: c.dir, CLEAN_DATABASE: "false", VERBOSE: "false",
}),
//Options we might want to customize
config_override
Expand Down
1 change: 0 additions & 1 deletion source/server/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const values = {
assets_dir: [undefined, toPath],
trust_proxy: [true, toBool],
hostname: [hostname(), toString],
hot_reload:[false, toBool],
smart_host: ["smtp://localhost", toString],
verbose: [false, toBool],
build_ref: ["unknown", toString],
Expand Down
Loading

0 comments on commit 909dd1b

Please sign in to comment.