Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit 23c45ee

Browse files
committed
feat(forge): remove unused locales
1 parent 825c2c1 commit 23c45ee

3 files changed

Lines changed: 36 additions & 0 deletions

File tree

apps/desktop/electron-forge/forge.config.cjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const path = require("path");
22
const fs = require("fs-extra");
3+
const { LOCALES } = require("@triliumnext/commons");
34

45
const ELECTRON_FORGE_DIR = __dirname;
56

@@ -141,6 +142,35 @@ module.exports = {
141142
}
142143
],
143144
hooks: {
145+
// Remove unused locales from the packaged app to save some space.
146+
postPackage(_, packageResult) {
147+
const localesToKeep = LOCALES
148+
.filter(locale => !locale.contentOnly)
149+
.map(locale => locale.electronLocale.replace("_", "-"));
150+
151+
for (const outputPath of packageResult.outputPaths) {
152+
const localesDir = path.join(outputPath, 'locales');
153+
154+
if (!fs.existsSync(localesDir)) {
155+
console.log('No locales directory found. Skipping cleanup.');
156+
return;
157+
}
158+
159+
const files = fs.readdirSync(localesDir);
160+
161+
for (const file of files) {
162+
const localeName = path.basename(file, ".pak");
163+
if (localesToKeep.includes(localeName)) {
164+
continue;
165+
}
166+
167+
console.log(`Removing unused locale file: ${file}`);
168+
const filePath = path.join(localesDir, file);
169+
fs.unlinkSync(filePath);
170+
}
171+
}
172+
},
173+
// Gather all the artifacts produced by the makers and copy them to a common upload directory.
144174
postMake(_, makeResults) {
145175
const outputDir = path.join(__dirname, "..", "upload");
146176
fs.mkdirpSync(outputDir);

apps/desktop/tsconfig.app.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"references": [
2525
{
2626
"path": "../server/tsconfig.app.json"
27+
},
28+
{
29+
"path": "../../packages/commons/tsconfig.lib.json"
2730
}
2831
]
2932
}

apps/desktop/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
{
77
"path": "../server"
88
},
9+
{
10+
"path": "../../packages/commons"
11+
},
912
{
1013
"path": "./tsconfig.app.json"
1114
}

0 commit comments

Comments
 (0)