diff --git a/apps/desktop/electron-forge/forge.config.cjs b/apps/desktop/electron-forge/forge.config.cjs index 3f81bb477..49a5ebf07 100644 --- a/apps/desktop/electron-forge/forge.config.cjs +++ b/apps/desktop/electron-forge/forge.config.cjs @@ -1,5 +1,6 @@ const path = require("path"); const fs = require("fs-extra"); +const { LOCALES } = require("@triliumnext/commons"); const ELECTRON_FORGE_DIR = __dirname; @@ -141,6 +142,35 @@ module.exports = { } ], hooks: { + // Remove unused locales from the packaged app to save some space. + postPackage(_, packageResult) { + const localesToKeep = LOCALES + .filter(locale => !locale.contentOnly) + .map(locale => locale.electronLocale.replace("_", "-")); + + for (const outputPath of packageResult.outputPaths) { + const localesDir = path.join(outputPath, 'locales'); + + if (!fs.existsSync(localesDir)) { + console.log('No locales directory found. Skipping cleanup.'); + return; + } + + const files = fs.readdirSync(localesDir); + + for (const file of files) { + const localeName = path.basename(file, ".pak"); + if (localesToKeep.includes(localeName)) { + continue; + } + + console.log(`Removing unused locale file: ${file}`); + const filePath = path.join(localesDir, file); + fs.unlinkSync(filePath); + } + } + }, + // Gather all the artifacts produced by the makers and copy them to a common upload directory. postMake(_, makeResults) { const outputDir = path.join(__dirname, "..", "upload"); fs.mkdirpSync(outputDir); diff --git a/apps/desktop/tsconfig.app.json b/apps/desktop/tsconfig.app.json index 24b95c5ed..ee86e5958 100644 --- a/apps/desktop/tsconfig.app.json +++ b/apps/desktop/tsconfig.app.json @@ -24,6 +24,9 @@ "references": [ { "path": "../server/tsconfig.app.json" + }, + { + "path": "../../packages/commons/tsconfig.lib.json" } ] } diff --git a/apps/desktop/tsconfig.json b/apps/desktop/tsconfig.json index 38116a0b8..6d58f2960 100644 --- a/apps/desktop/tsconfig.json +++ b/apps/desktop/tsconfig.json @@ -6,6 +6,9 @@ { "path": "../server" }, + { + "path": "../../packages/commons" + }, { "path": "./tsconfig.app.json" }