Skip to content

Build your personal knowledge base with Trilium Notes

fix(server): not running in prod due to webpack change

Elian Doran42a7556c558e
diff --git a/src/app.ts b/src/app.ts
index f6ed4e1811..a3943b7131 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -57,7 +57,7 @@ app.use(`/icon.png`, express.static(path.join(scriptDir, 'public/icon.png')));
app.use(sessionParser);
app.use(favicon(`${scriptDir}/../images/app-icons/icon.ico`));
-assets.register(app);
+await assets.register(app);
routes.register(app);
custom.register(app);
error_handlers.register(app);
diff --git a/src/routes/assets.ts b/src/routes/assets.ts
index 9c16c91a94..a634483ce7 100644
--- a/src/routes/assets.ts
+++ b/src/routes/assets.ts
@@ -4,8 +4,6 @@ import { fileURLToPath } from "url";
import express from "express";
import env from "../services/env.js";
import serveStatic from "serve-static";
-import webpack from "webpack";
-import webpackMiddleware from "webpack-dev-middleware";
const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOptions<express.Response<any, Record<string, any>>>) => {
if (!env.isDev()) {
@@ -17,9 +15,12 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOp
return express.static(root, options);
};
-function register(app: express.Application) {
+async function register(app: express.Application) {
const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');
if (env.isDev()) {
+ const webpack = (await import("webpack")).default;
+ const webpackMiddleware = (await import("webpack-dev-middleware")).default;
+
const frontendCompiler = webpack({
mode: "development",
entry: {