mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
allow template hot reload
This commit is contained in:
1 parent
a29c4ebf77
commit
32df811bfa
2 files changed
+12
-3
No files matched your search
+1
-2
@@ -10,7 +10,6 @@
|
||||
"build:watch": "node build/build.js --watch",
|
||||
"build:ui": "node packages/ui-default/build",
|
||||
"build:ui:dev": "node packages/ui-default/build --dev",
|
||||
"build:ui:watch": "node packages/ui-default/build --watch",
|
||||
"build:ui:production": "node packages/ui-default/build --production",
|
||||
"lint": "eslint packages --ext ts --fix",
|
||||
"lint:ci": "eslint packages --ext ts",
|
||||
@@ -19,7 +18,7 @@
|
||||
"snowpack": "cd packages/ui-default && snowpack dev",
|
||||
"pub": "node build/publish",
|
||||
"jest": "node build/jest",
|
||||
"debug": "node --async-stack-traces --trace-deprecation --enable-source-maps build/start --debug",
|
||||
"debug": "node --async-stack-traces --trace-deprecation --enable-source-maps build/start --debug --template",
|
||||
"start": "node build/start",
|
||||
"clean": "zsh -c \"rm -rf tsconfig.build.tsbuildinfo ./packages/*/tsconfig.tsbuildinfo ./packages/*/dist ./.coverage\""
|
||||
},
|
||||
|
||||
@@ -88,9 +88,19 @@ class Loader extends nunjucks.Loader {
|
||||
};
|
||||
}
|
||||
let fullpath = null;
|
||||
if (typeof argv.template !== 'string') argv.template = path.resolve(__dirname, '..', 'template');
|
||||
const p = path.resolve(process.cwd(), argv.template, name);
|
||||
if (fs.existsSync(p)) fullpath = p;
|
||||
if (!fullpath) throw new Error(`Cannot get template ${name}`);
|
||||
if (!fullpath) {
|
||||
if (global.Hydro.ui.template[name]) {
|
||||
return {
|
||||
src: global.Hydro.ui.template[name],
|
||||
path: name,
|
||||
noCache: true,
|
||||
};
|
||||
}
|
||||
throw new Error(`Cannot get template ${name}`);
|
||||
}
|
||||
return {
|
||||
src: fs.readFileSync(fullpath, 'utf-8').toString(),
|
||||
path: fullpath,
|
||||
|
||||
Reference in new issue
Block a user