Skip to content

Commit

Permalink
disable HMR, tailwind is dumb
Browse files Browse the repository at this point in the history
Add Shadcn-vue
  • Loading branch information
GaryCraft committed Jun 24, 2024
1 parent f3cb5f2 commit 07037cf
Show file tree
Hide file tree
Showing 118 changed files with 6,866 additions and 1,072 deletions.
239 changes: 78 additions & 161 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

62 changes: 41 additions & 21 deletions src/modules/webui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,55 @@ const HMR_PORT = 1421;

export default {
name: "webui",

loadFunction: async (config) => {
return new EventEmitter();
},
initFunction: async (ctx, config) => {
const appCtx = getAppContext();
const isProduction = process.env.NODE_ENV !== "development"
const isProduction = process.env.NODE_ENV === "production";
const v = await import("vite");
let vite;

if (isProduction) {
const result = await buildWebUI(WebBuildFromPath, WebBuildToPath);
if (!result) {
error("Failed to build webui");
return;
} else {
info("WebUI built successfully");
}
const clientPath = path.join(WebBuildToPath, "client");
// Expect the web build to be in the public directory
if (!fs.existsSync(clientPath)) {
error("Web build not found in public directory");
return;
// When HMR is working, move this to the isProduction block
const result = await buildWebUI(WebBuildFromPath, WebBuildToPath);
if (!result) {
error("Failed to build webui");
return;
} else {
info("WebUI built successfully");
}

const clientPath = path.join(WebBuildToPath, "client");
// Expect the web build to be in the public directory
if (!fs.existsSync(clientPath)) {
error("Web build not found in public directory");
return;
}
appCtx.http.server.use(express.static("web/dist/client"));

// Watch for changes in the web directory and rebuild
fs.watch(path.join(
WebBuildFromPath,
"src"
), { recursive: true }, async (event, filename) => {
if (filename) {
const result = await buildWebUI(WebBuildFromPath, WebBuildToPath);
if (!result) {
error("Failed to build webui");
return;
} else {
info("WebUI built successfully");
}
}
appCtx.http.server.use(express.static("web/dist/client"));
});
/* if (isProduction) {
// provisionally empty
} else {
// Vite dev server
debug("Starting Vite dev server");
vite = await v.createServer({
configFile: path.join(WebBuildFromPath, "vite.config.ts"),
root: WebBuildFromPath,
server: { middlewareMode: true, hmr: { port: HMR_PORT } },
appType: "custom",
Expand All @@ -65,9 +85,9 @@ export default {
debug("Vite dev server started");
}
if (!vite) {
// error("Vite dev server not started, exiting");
return;
if(!vite){
error("Vite not initialized")
return
}
const template = isProduction ?
Expand All @@ -79,7 +99,7 @@ export default {
)
)
const render = isProduction ?
(await import(`${WebBuildToPath}/server/entry-server.js`)).render :
(require(`${WebBuildToPath}/server/entry-server.js`)).render :
(
await vite.ssrLoadModule(
path.join(WebBuildFromPath, '/src/entry-server')
Expand Down Expand Up @@ -109,6 +129,6 @@ export default {
error("Error serving web page", e)
res.status(500).send("Internal Server Error")
}
})
}) */
}
} satisfies Module<EventEmitter, "none">;
Loading

0 comments on commit 07037cf

Please sign in to comment.