core&ui: enhanced template hot reload

This commit is contained in:
undefined committed 2023-04-14 11:44:14 +08:00
1 parent b5d51f3372
commit 5588fd9a9d
3 files changed
+14 -9

No files matched your search

+4 -2
View File
@@ -147,8 +147,10 @@ export async function template(pending: string[], fail: string[]) {
try {
const files = await getFiles(p);
for (const file of files) {
if (file.endsWith('.tsx')) global.Hydro.ui.template[file] = require(path.resolve(p, file));
global.Hydro.ui.template[file] = await fs.readFile(path.resolve(p, file), 'utf-8');
const l = path.resolve(p, file);
if (file.endsWith('.tsx')) global.Hydro.ui.template[file] = require(l);
global.Hydro.ui.template[file] = await fs.readFile(l, 'utf-8');
if (process.env.DEV) global.Hydro.ui.template[`${file}.source`] = l;
}
logger.info('Template init: %s', i);
} catch (e) {