Skip to content

Build your personal knowledge base with Trilium Notes

feat(presentation): compile the vendored themes instead of the prebuilt CSS

Elian Doran89e4c64bda72
diff --git a/apps/client/package.json b/apps/client/package.json
index d3804f2083..15193112bf 100644
--- a/apps/client/package.json
+++ b/apps/client/package.json
@@ -84,6 +84,7 @@
"happy-dom": "20.11.6",
"jsdom": "30.0.1",
"lightningcss": "1.33.0",
+ "sass": "1.103.1",
"stylelint": "17.14.1",
"vite-plugin-static-copy": "4.1.1"
}
diff --git a/apps/client/src/widgets/collections/presentation/themes.spec.ts b/apps/client/src/widgets/collections/presentation/themes.spec.ts
index 854cad1908..bf4e223bc1 100644
--- a/apps/client/src/widgets/collections/presentation/themes.spec.ts
+++ b/apps/client/src/widgets/collections/presentation/themes.spec.ts
@@ -1,10 +1,27 @@
-import { it, describe } from "vitest";
+import { describe, expect, it } from "vitest";
import { getPresentationThemes, loadPresentationTheme } from "./themes";
describe("Presentation themes", () => {
it("can load all themes", async () => {
const themes = getPresentationThemes();
+ const stylesheets = await Promise.all(themes.map(theme => loadPresentationTheme(theme.id)));
- await Promise.all(themes.map(theme => loadPresentationTheme(theme.id)));
+ for (const [ index, stylesheet ] of stylesheets.entries()) {
+ const id = themes[index].id;
+
+ // Every theme drives reveal.js through the custom properties the template emits.
+ expect(stylesheet, id).toContain("--r-main-font");
+ expect(stylesheet, id).toContain("--r-background-color");
+
+ // The vendored sources carry no fonts: no inlined face, and nothing fetched at render
+ // time. See reveal-themes/README.md.
+ expect(stylesheet, id).not.toContain("@font-face");
+ expect(stylesheet, id).not.toContain("base64");
+ expect(stylesheet, id).not.toContain("fonts.googleapis.com");
+ }
+ });
+
+ it("falls back to the default theme for an unknown name", async () => {
+ expect(await loadPresentationTheme("no-such-theme")).toBe(await loadPresentationTheme("white"));
});
});
diff --git a/apps/client/src/widgets/collections/presentation/themes.ts b/apps/client/src/widgets/collections/presentation/themes.ts
index ebd2a9c341..2a8886976d 100644
--- a/apps/client/src/widgets/collections/presentation/themes.ts
+++ b/apps/client/src/widgets/collections/presentation/themes.ts
@@ -3,43 +3,43 @@ export const DEFAULT_THEME = "white";
const themes = {
black: {
name: "Black",
- loadTheme: () => import("reveal.js/theme/black.css?raw")
+ loadTheme: () => import("./reveal-themes/black.scss?inline")
},
white: {
name: "White",
- loadTheme: () => import("reveal.js/theme/white.css?raw")
+ loadTheme: () => import("./reveal-themes/white.scss?inline")
},
beige: {
name: "Beige",
- loadTheme: () => import("reveal.js/theme/beige.css?raw")
+ loadTheme: () => import("./reveal-themes/beige.scss?inline")
},
serif: {
name: "Serif",
- loadTheme: () => import("reveal.js/theme/serif.css?raw")
+ loadTheme: () => import("./reveal-themes/serif.scss?inline")
},
simple: {
name: "Simple",
- loadTheme: () => import("reveal.js/theme/simple.css?raw")
+ loadTheme: () => import("./reveal-themes/simple.scss?inline")
},
solarized: {
name: "Solarized",
- loadTheme: () => import("reveal.js/theme/solarized.css?raw")
+ loadTheme: () => import("./reveal-themes/solarized.scss?inline")
},
moon: {
name: "Moon",
- loadTheme: () => import("reveal.js/theme/moon.css?raw")
+ loadTheme: () => import("./reveal-themes/moon.scss?inline")
},
dracula: {
name: "Dracula",
- loadTheme: () => import("reveal.js/theme/dracula.css?raw")
+ loadTheme: () => import("./reveal-themes/dracula.scss?inline")
},
sky: {
name: "Sky",
- loadTheme: () => import("reveal.js/theme/sky.css?raw")
+ loadTheme: () => import("./reveal-themes/sky.scss?inline")
},
blood: {
name: "Blood",
- loadTheme: () => import("reveal.js/theme/blood.css?raw")
+ loadTheme: () => import("./reveal-themes/blood.scss?inline")
}
} as const;
diff --git a/apps/client/vite.config.mts b/apps/client/vite.config.mts
index b087bc7a90..ec9dbdb91b 100644
--- a/apps/client/vite.config.mts
+++ b/apps/client/vite.config.mts
@@ -127,6 +127,10 @@ export default defineConfig(() => ({
},
test: {
environment: "happy-dom",
+ // Vitest skips CSS processing by default, which would hand `?inline` importers an empty
+ // string. The presentation themes are SCSS compiled through that path, so their specs need
+ // it on to assert against real rules.
+ css: { include: [/\.scss(\?|$)/] },
setupFiles: [
"./src/test/setup.ts"
],
diff --git a/apps/standalone/package.json b/apps/standalone/package.json
index 895e4f4269..65f8243e35 100644
--- a/apps/standalone/package.json
+++ b/apps/standalone/package.json
@@ -76,6 +76,7 @@
"@types/tabulator-tables": "6.3.6",
"cross-env": "10.1.0",
"happy-dom": "20.11.6",
+ "sass": "1.103.1",
"vite-plugin-static-copy": "4.1.1"
}
}
\ No newline at end of file
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1c33a9191e..5a2b7721a2 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -112,7 +112,7 @@ importers:
'@vitest/browser-webdriverio':
specifier: 4.1.11
'@vitest/coverage-v8':
specifier: 4.1.11
version: 4.1.11(@vitest/[email protected])([email protected])
@@ -166,10 +166,10 @@ importers:
vite:
specifier: 8.2.2
vitest:
specifier: 4.1.11
apps/build-docs:
dependencies:
@@ -366,10 +366,10 @@ importers:
version: 5.0.3
'@codecov/vite-plugin':
specifier: 2.0.1
'@prefresh/vite':
specifier: 3.0.1
'@types/bootstrap':
specifier: 5.2.11
version: 5.2.11
@@ -394,12 +394,15 @@ importers:
lightningcss:
specifier: 1.33.0
version: 1.33.0
+ sass:
+ specifier: 1.103.1
+ version: 1.103.1
stylelint:
specifier: 17.14.1
vite-plugin-static-copy:
specifier: 4.1.1
apps/db-compare:
dependencies:
@@ -418,7 +421,7 @@ importers:
version: 9.6.0
vitest:
specifier: 4.1.11
apps/desktop:
dependencies:
@@ -804,7 +807,7 @@ importers:
version: 2.1.0
vite:
specifier: 8.2.2
yauzl:
specifier: 3.4.0
version: 3.4.0
@@ -964,10 +967,10 @@ importers:
version: 5.0.3
'@codecov/vite-plugin':
specifier: 2.0.1
'@prefresh/vite':
specifier: 3.0.1
'@types/aes-js':
specifier: 3.1.4
version: 3.1.4
@@ -992,9 +995,12 @@ importers:
happy-dom:
specifier: 20.11.6
version: 20.11.6
+ sass:
+ specifier: 1.103.1
+ version: 1.103.1
vite-plugin-static-copy:
specifier: 4.1.1
apps/web-clipper:
dependencies:
@@ -1004,13 +1010,13 @@ importers:
devDependencies:
'@wxt-dev/auto-icons':
specifier: 1.1.2
jszip:
specifier: 3.10.1
version: 3.10.1
wxt:
specifier: 0.21.4
apps/website:
dependencies:
@@ -1032,7 +1038,7 @@ importers:
devDependencies:
'@preact/preset-vite':
specifier: 2.10.6
eslint:
specifier: 10.8.1
@@ -1047,10 +1053,10 @@ importers:
version: 0.4.3
vite:
specifier: 8.2.2
vitest:
specifier: 4.1.11
packages/ckeditor5:
dependencies:
@@ -1072,10 +1078,10 @@ importers:
devDependencies:
'@vitest/browser':
specifier: 4.1.11
vitest:
specifier: 4.1.11
webdriverio:
specifier: 9.31.1
version: 9.31.1([email protected])
@@ -1367,7 +1373,7 @@ importers:
version: 20.11.6
vitest:
specifier: 4.1.11
packages/trilium-backup-container:
dependencies:
@@ -1485,7 +1491,7 @@ importers:
version: 1.12.2
vitest:
specifier: 4.1.11
packages:
@@ -8558,8 +8564,8 @@ packages:
resolution: {integrity: sha512-HR7EVodfFUdQCTIeySw+WDRFJlPcLOJbXfwwZ7Oom6tjsvZ3bOkCDJHehQC3nxJrv7+f9XecwazynjU8e4Vw3Q==}
- resolution: {integrity: sha512-d/Ld9aLbKpNwyl0KiM2CT1WYvkitQ1TSvmRtkcV8FKStiDoA7Slzgjmb/1G2yhKM1p0XeNOieaTbFZmU1d3Xuw==}
+ resolution: {integrity: sha512-m8nVez3rwrgmWxtLMt1ZYXB2Lv7OKYn/disyxAlSDYAlKSlFoPPfIAmAM/M5xqL4m4C/wAPw7S2/CNaUii1Hxg==}
resolution: {integrity: sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==}
@@ -10891,6 +10897,11 @@ packages:
resolution: {integrity: sha512-PGtEkc9cbnedU3s9TmzDbpsZ8w086g/0Q8k8/oIO1NLNU3i5k9yn835CrjJSajp1KMmkisbO1qPXxNKO3welAg==}
engines: {node: '>=22.12.0'}
+ resolution: {integrity: sha512-9icZURbP51S6S0QGoyaeqk9uB06GNWxsFYWfH5RgpFgqK5FA8tJcM3AdVxrZEVJ7dz+L87nG95gBKf4VuaMHGw==}
+ engines: {node: '>=20.19.0'}
+ hasBin: true
+
resolution: {integrity: sha512-haGdpTgywJTvHC2b91GSq+clTKGbtkkZmVAb82jZQN/wTy6qs8DdFm2lhEQbEwrY0QDRgSQ3xDurqM977C3noA==}
engines: {node: '>=12.0.0'}
@@ -12428,6 +12439,7 @@ packages:
ignoredOptionalDependencies:
- '@anthropic-ai/claude-agent-sdk-*'
+ - '@parcel/watcher'
snapshots:
@@ -13354,11 +13366,11 @@ snapshots:
unplugin: 1.16.1
zod: 4.4.3
dependencies:
'@codecov/bundler-plugin-core': 2.0.1
unplugin: 1.16.1
'@codemirror/[email protected]':
dependencies:
@@ -15533,19 +15545,19 @@ snapshots:
'@popperjs/[email protected]': {}
dependencies:
'@babel/core': 7.29.0([email protected])
'@babel/plugin-transform-react-jsx': 7.28.6(@babel/[email protected]([email protected]))([email protected])
'@babel/plugin-transform-react-jsx-development': 7.27.1(@babel/[email protected]([email protected]))([email protected])
'@rollup/pluginutils': 5.3.0
babel-plugin-transform-hook-names: 1.0.2(@babel/[email protected]([email protected]))
debug: 4.4.3([email protected])
magic-string: 0.30.21
picocolors: 1.1.1
zimmerframe: 1.1.4
transitivePeerDependencies:
- preact
@@ -15565,19 +15577,19 @@ snapshots:
dependencies:
preact: 10.29.8([email protected])
dependencies:
oxc-unshadowed-visitor: 0.0.1([email protected])
rolldown: 1.0.1
rolldown-string: 0.3.0([email protected])
optionalDependencies:
transitivePeerDependencies:
- oxc-parser
'@prefresh/[email protected]': {}
dependencies:
'@babel/core': 7.29.0([email protected])
'@prefresh/babel-plugin': 0.5.3
@@ -15585,21 +15597,21 @@ snapshots:
'@prefresh/utils': 1.2.1
'@rollup/pluginutils': 4.2.1
preact: 10.29.8([email protected])
transitivePeerDependencies:
- supports-color
dependencies:
'@babel/core': 7.29.0([email protected])
'@prefresh/babel-plugin': 0.5.3
'@prefresh/core': 1.5.10([email protected])
'@prefresh/utils': 1.2.1
'@rollup/pluginutils': 4.2.1
preact: 10.29.8([email protected])
rolldown: 1.0.1
transitivePeerDependencies:
- oxc-parser
- supports-color
@@ -18333,10 +18345,10 @@ snapshots:
'@vercel/[email protected]': {}
dependencies:
webdriverio: 9.31.1([email protected])
transitivePeerDependencies:
- bufferutil
@@ -18344,16 +18356,16 @@ snapshots:
- utf-8-validate
- vite
dependencies:
'@blazediff/core': 1.9.1
'@vitest/utils': 4.1.11
magic-string: 0.30.21
pngjs: 7.0.0
sirv: 3.0.2
tinyrainbow: 3.1.0
ws: 8.21.0
transitivePeerDependencies:
- bufferutil
@@ -18373,9 +18385,9 @@ snapshots:
obug: 2.1.3
std-env: 4.1.0
tinyrainbow: 3.1.0
optionalDependencies:
'@vitest/[email protected]':
dependencies:
@@ -18386,13 +18398,13 @@ snapshots:
chai: 6.2.2
tinyrainbow: 3.1.0
dependencies:
'@vitest/spy': 4.1.11
estree-walker: 3.0.3
magic-string: 0.30.21
optionalDependencies:
'@vitest/[email protected]':
dependencies:
@@ -18421,7 +18433,7 @@ snapshots:
sirv: 3.0.2
tinyglobby: 0.2.17
tinyrainbow: 3.1.0
'@vitest/[email protected]':
dependencies:
@@ -18581,11 +18593,11 @@ snapshots:
'@workflow/[email protected]': {}
dependencies:
defu: 6.1.7
sharp: 0.35.3(@types/[email protected])
transitivePeerDependencies:
- '@types/node'
@@ -21862,7 +21874,7 @@ snapshots:
dependencies:
@@ -22257,7 +22269,7 @@ snapshots:
dependencies:
- '@babel/runtime': 7.29.2
+ '@babel/runtime': 7.29.7
ts-algebra: 2.0.0
@@ -24456,10 +24468,16 @@ snapshots:
parse-srcset: 1.0.2
postcss: 8.5.25
+ dependencies:
+ chokidar: 5.0.0
+ immutable: 5.1.9
+ source-map-js: 1.2.1
+
dependencies:
chokidar: 3.6.0
- immutable: 4.3.8
+ immutable: 5.1.9
source-map-js: 1.2.1
@@ -25688,15 +25706,15 @@ snapshots:
'@types/unist': 3.0.3
vfile-message: 4.0.3
dependencies:
chokidar: 3.6.0
p-map: 7.0.4
picocolors: 1.1.1
tinyglobby: 0.2.17
dependencies:
kolorist: 1.8.0
magic-string: 0.30.21
@@ -25704,9 +25722,9 @@ snapshots:
simple-code-frame: 1.3.0
source-map: 0.7.6
stack-trace: 1.0.0
dependencies:
lightningcss: 1.33.0
picomatch: 4.0.5
@@ -25718,14 +25736,15 @@ snapshots:
esbuild: 0.28.2
fsevents: 2.3.3
jiti: 2.7.0
+ sass: 1.103.1
terser: 5.47.1
tsx: 4.23.12
yaml: 2.9.0
dependencies:
'@vitest/expect': 4.1.11
'@vitest/pretty-format': 4.1.11
'@vitest/runner': 4.1.11
'@vitest/snapshot': 4.1.11
@@ -25742,12 +25761,12 @@ snapshots:
tinyexec: 1.3.0
tinyglobby: 0.2.17
tinyrainbow: 3.1.0
why-is-node-running: 2.3.0
optionalDependencies:
'@opentelemetry/api': 1.9.1
'@types/node': 24.13.3
'@vitest/coverage-v8': 4.1.11(@vitest/[email protected])([email protected])
'@vitest/ui': 4.1.11([email protected])
happy-dom: 20.11.6
@@ -26038,7 +26057,7 @@ snapshots:
dependencies:
'@1natsu/wait-element': 4.2.0
'@aklinker1/rollup-plugin-visualizer': 5.12.0
@@ -26069,7 +26088,7 @@ snapshots:
tinyexec: 1.3.0
tinyglobby: 0.2.17
unimport: 6.3.0([email protected])
optionalDependencies:
typescript: 6.0.3
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 872566a8bf..b097ad9878 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -114,6 +114,9 @@ overrides:
# CI install on its PRs (ERR_PNPM_LOCKFILE_CONFIG_MISMATCH).
ignoredOptionalDependencies:
- "@anthropic-ai/claude-agent-sdk-*"
+ # sass wants @parcel/watcher for its --watch mode, which nothing here invokes -- Vite drives the
+ # compiler API. Skipping it avoids a native install script and twelve per-platform binaries.
+ - "@parcel/watcher"
patchedDependencies:
'@excalidraw/[email protected]': patches/@[email protected]