Skip to content

Build your personal knowledge base with Trilium Notes

fix(dx/client): client not starting due to duplicate config

Elian Doran35743de0dfe4
diff --git a/apps/client/vite.config.mts b/apps/client/vite.config.mts
index 29ee10ef59..a07d6120fd 100644
--- a/apps/client/vite.config.mts
+++ b/apps/client/vite.config.mts
@@ -7,12 +7,18 @@ import preact from "@preact/preset-vite";
const assets = [ "assets", "stylesheets", "fonts", "translations" ];
-export default defineConfig(() => ({
- root: __dirname,
- cacheDir: '../../node_modules/.vite/apps/client',
- base: "",
- plugins: [
- preact(),
+const isDev = process.env.NODE_ENV === "development";
+let plugins: any = [
+ preact({
+ babel: {
+ compact: !isDev
+ }
+ })
+];
+
+if (!isDev) {
+ plugins = [
+ ...plugins,
viteStaticCopy({
targets: assets.map((asset) => ({
src: `src/${asset}/*`,
@@ -29,7 +35,14 @@ export default defineConfig(() => ({
]
}),
webpackStatsPlugin()
- ] as Plugin[],
+ ]
+}
+
+export default defineConfig(() => ({
+ root: __dirname,
+ cacheDir: '../../node_modules/.vite/apps/client',
+ base: "",
+ plugins,
resolve: {
alias: [
{
diff --git a/apps/server/src/routes/assets.ts b/apps/server/src/routes/assets.ts
index 6c8dc6bc37..02e69c4499 100644
--- a/apps/server/src/routes/assets.ts
+++ b/apps/server/src/routes/assets.ts
@@ -27,17 +27,7 @@ async function register(app: express.Application) {
appType: "custom",
cacheDir: path.join(srcRoot, "../../.cache/vite"),
base: `/${assetUrlFragment}/`,
- root: path.join(srcRoot, "../client"),
- plugins: [
- preact({
- babel: {
- compact: false
- }
- })
- ],
- define: {
- "process.env.IS_PREACT": JSON.stringify("true"),
- }
+ root: path.join(srcRoot, "../client")
});
app.use(`/${assetUrlFragment}/`, (req, res, next) => {
req.url = `/${assetUrlFragment}` + req.url;