mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: enhanced template hot reload
This commit is contained in:
3 files changed
+14
-9
No files matched your search
@@ -18,7 +18,7 @@ export function register(cli: CAC) {
|
||||
let addons = JSON.parse(fs.readFileSync(addonPath).toString());
|
||||
if (operation === 'create') {
|
||||
const dir = `${addonDir}/${name || 'addon'}`;
|
||||
fs.mkdirSync(dir);
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
child.execSync('yarn init -y', { cwd: dir });
|
||||
fs.mkdirSync(`${dir}/templates`);
|
||||
fs.mkdirSync(`${dir}/locales`);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user