mirror of
https://github.com/zadam/trilium.git
synced 2026-01-01 12:14:24 +01:00
feat(pdfjs): auto-watch dev
This commit is contained in:
parent
0a9ce84cf2
commit
fffab73061
@ -3,7 +3,8 @@
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "tsx scripts/build.ts"
|
||||
"build": "tsx scripts/build.ts",
|
||||
"watch": "tsx scripts/build.ts --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@triliumnext/commons": "workspace:*"
|
||||
|
||||
@ -2,8 +2,10 @@ import { join } from "path";
|
||||
import BuildHelper from "../../../scripts/build-utils";
|
||||
import { build as esbuild } from "esbuild";
|
||||
import { LOCALES } from "@triliumnext/commons";
|
||||
import { watch } from "chokidar";
|
||||
|
||||
const build = new BuildHelper("packages/pdfjs-viewer");
|
||||
const watchMode = process.argv.includes("--watch");
|
||||
|
||||
const LOCALE_MAPPINGS: Record<string, string> = {
|
||||
"es": "es-ES"
|
||||
@ -34,6 +36,10 @@ async function main() {
|
||||
// Copy pdfjs-dist files.
|
||||
build.copy("/node_modules/pdfjs-dist/build/pdf.mjs", "build/pdf.mjs");
|
||||
build.copy("/node_modules/pdfjs-dist/build/pdf.worker.mjs", "build/pdf.worker.mjs");
|
||||
|
||||
if (watchMode) {
|
||||
watchForChanges();
|
||||
}
|
||||
}
|
||||
|
||||
async function buildScript(outPath: string) {
|
||||
@ -48,4 +54,28 @@ async function buildScript(outPath: string) {
|
||||
});
|
||||
}
|
||||
|
||||
async function rebuildCustomFiles() {
|
||||
await buildScript("web/custom.mjs");
|
||||
build.copy("src/custom.css", "web/custom.css");
|
||||
}
|
||||
|
||||
function watchForChanges() {
|
||||
console.log("Watching for changes in src directory...");
|
||||
const watcher = watch(join(build.projectDir, "src"), {
|
||||
persistent: true,
|
||||
ignoreInitial: true,
|
||||
});
|
||||
|
||||
watcher.on("all", async (event, path) => {
|
||||
console.log(`File ${event}: ${path}`);
|
||||
console.log("Rebuilding...");
|
||||
try {
|
||||
await rebuildCustomFiles();
|
||||
console.log("Rebuild complete!");
|
||||
} catch (error) {
|
||||
console.error("Build failed:", error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
@ -3,6 +3,7 @@ import interceptPersistence from "./persistence";
|
||||
const LOG_EVENT_BUS = false;
|
||||
|
||||
async function main() {
|
||||
console.log("Hi");
|
||||
interceptPersistence(getCustomAppOptions());
|
||||
|
||||
// Wait for the PDF viewer application to be available.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user