fix createApp() fn doesn't require config, fix admin controller main entry

This commit is contained in:
dswbx
2024-12-10 08:44:50 +01:00
parent 86a7bee3d9
commit 847b08b505
2 changed files with 12 additions and 4 deletions

View File

@@ -14,7 +14,7 @@ const htmlBkndContextReplace = "<!-- BKND_CONTEXT -->";
export type AdminControllerOptions = {
basepath?: string;
html?: string;
forceDev?: boolean;
forceDev?: boolean | { mainPath: string };
};
export class AdminController implements ClassController {
@@ -108,7 +108,10 @@ export class AdminController implements ClassController {
if (this.options.html) {
if (this.options.html.includes(htmlBkndContextReplace)) {
return this.options.html.replace(htmlBkndContextReplace, bknd_context);
return this.options.html.replace(
htmlBkndContextReplace,
"<script>" + bknd_context + "</script>"
);
}
console.warn(
@@ -119,6 +122,10 @@ export class AdminController implements ClassController {
const configs = this.app.modules.configs();
const isProd = !isDebug() && !this.options.forceDev;
const mainPath =
typeof this.options.forceDev === "object" && "mainPath" in this.options.forceDev
? this.options.forceDev.mainPath
: "/src/ui/main.tsx";
const assets = {
js: "main.js",
@@ -172,13 +179,14 @@ export class AdminController implements ClassController {
)}
</head>
<body>
<div id="root" />
<div id="app" />
<script
dangerouslySetInnerHTML={{
__html: bknd_context
}}
/>
{!isProd && <script type="module" src="/src/ui/main.tsx" />}
{!isProd && <script type="module" src={mainPath} />}
</body>
</html>
</Fragment>